api.rst 314 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===================================================================
  3. The Definitive KVM (Kernel-based Virtual Machine) API Documentation
  4. ===================================================================
  5. 1. General description
  6. ======================
  7. The kvm API is a set of ioctls that are issued to control various aspects
  8. of a virtual machine. The ioctls belong to the following classes:
  9. - System ioctls: These query and set global attributes which affect the
  10. whole kvm subsystem. In addition a system ioctl is used to create
  11. virtual machines.
  12. - VM ioctls: These query and set attributes that affect an entire virtual
  13. machine, for example memory layout. In addition a VM ioctl is used to
  14. create virtual cpus (vcpus) and devices.
  15. VM ioctls must be issued from the same process (address space) that was
  16. used to create the VM.
  17. - vcpu ioctls: These query and set attributes that control the operation
  18. of a single virtual cpu.
  19. vcpu ioctls should be issued from the same thread that was used to create
  20. the vcpu, except for asynchronous vcpu ioctl that are marked as such in
  21. the documentation. Otherwise, the first ioctl after switching threads
  22. could see a performance impact.
  23. - device ioctls: These query and set attributes that control the operation
  24. of a single device.
  25. device ioctls must be issued from the same process (address space) that
  26. was used to create the VM.
  27. 2. File descriptors
  28. ===================
  29. The kvm API is centered around file descriptors. An initial
  30. open("/dev/kvm") obtains a handle to the kvm subsystem; this handle
  31. can be used to issue system ioctls. A KVM_CREATE_VM ioctl on this
  32. handle will create a VM file descriptor which can be used to issue VM
  33. ioctls. A KVM_CREATE_VCPU or KVM_CREATE_DEVICE ioctl on a VM fd will
  34. create a virtual cpu or device and return a file descriptor pointing to
  35. the new resource. Finally, ioctls on a vcpu or device fd can be used
  36. to control the vcpu or device. For vcpus, this includes the important
  37. task of actually running guest code.
  38. In general file descriptors can be migrated among processes by means
  39. of fork() and the SCM_RIGHTS facility of unix domain socket. These
  40. kinds of tricks are explicitly not supported by kvm. While they will
  41. not cause harm to the host, their actual behavior is not guaranteed by
  42. the API. See "General description" for details on the ioctl usage
  43. model that is supported by KVM.
  44. It is important to note that although VM ioctls may only be issued from
  45. the process that created the VM, a VM's lifecycle is associated with its
  46. file descriptor, not its creator (process). In other words, the VM and
  47. its resources, *including the associated address space*, are not freed
  48. until the last reference to the VM's file descriptor has been released.
  49. For example, if fork() is issued after ioctl(KVM_CREATE_VM), the VM will
  50. not be freed until both the parent (original) process and its child have
  51. put their references to the VM's file descriptor.
  52. Because a VM's resources are not freed until the last reference to its
  53. file descriptor is released, creating additional references to a VM
  54. via fork(), dup(), etc... without careful consideration is strongly
  55. discouraged and may have unwanted side effects, e.g. memory allocated
  56. by and on behalf of the VM's process may not be freed/unaccounted when
  57. the VM is shut down.
  58. 3. Extensions
  59. =============
  60. As of Linux 2.6.22, the KVM ABI has been stabilized: no backward
  61. incompatible change are allowed. However, there is an extension
  62. facility that allows backward-compatible extensions to the API to be
  63. queried and used.
  64. The extension mechanism is not based on the Linux version number.
  65. Instead, kvm defines extension identifiers and a facility to query
  66. whether a particular extension identifier is available. If it is, a
  67. set of ioctls is available for application use.
  68. 4. API description
  69. ==================
  70. This section describes ioctls that can be used to control kvm guests.
  71. For each ioctl, the following information is provided along with a
  72. description:
  73. Capability:
  74. which KVM extension provides this ioctl. Can be 'basic',
  75. which means that is will be provided by any kernel that supports
  76. API version 12 (see section 4.1), a KVM_CAP_xyz constant, which
  77. means availability needs to be checked with KVM_CHECK_EXTENSION
  78. (see section 4.4), or 'none' which means that while not all kernels
  79. support this ioctl, there's no capability bit to check its
  80. availability: for kernels that don't support the ioctl,
  81. the ioctl returns -ENOTTY.
  82. Architectures:
  83. which instruction set architectures provide this ioctl.
  84. x86 includes both i386 and x86_64.
  85. Type:
  86. system, vm, or vcpu.
  87. Parameters:
  88. what parameters are accepted by the ioctl.
  89. Returns:
  90. the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  91. are not detailed, but errors with specific meanings are.
  92. 4.1 KVM_GET_API_VERSION
  93. -----------------------
  94. :Capability: basic
  95. :Architectures: all
  96. :Type: system ioctl
  97. :Parameters: none
  98. :Returns: the constant KVM_API_VERSION (=12)
  99. This identifies the API version as the stable kvm API. It is not
  100. expected that this number will change. However, Linux 2.6.20 and
  101. 2.6.21 report earlier versions; these are not documented and not
  102. supported. Applications should refuse to run if KVM_GET_API_VERSION
  103. returns a value other than 12. If this check passes, all ioctls
  104. described as 'basic' will be available.
  105. 4.2 KVM_CREATE_VM
  106. -----------------
  107. :Capability: basic
  108. :Architectures: all
  109. :Type: system ioctl
  110. :Parameters: machine type identifier (KVM_VM_*)
  111. :Returns: a VM fd that can be used to control the new virtual machine.
  112. The new VM has no virtual cpus and no memory.
  113. You probably want to use 0 as machine type.
  114. X86:
  115. ^^^^
  116. Supported X86 VM types can be queried via KVM_CAP_VM_TYPES.
  117. S390:
  118. ^^^^^
  119. In order to create user controlled virtual machines on S390, check
  120. KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL as
  121. privileged user (CAP_SYS_ADMIN).
  122. MIPS:
  123. ^^^^^
  124. To use hardware assisted virtualization on MIPS (VZ ASE) rather than
  125. the default trap & emulate implementation (which changes the virtual
  126. memory layout to fit in user mode), check KVM_CAP_MIPS_VZ and use the
  127. flag KVM_VM_MIPS_VZ.
  128. ARM64:
  129. ^^^^^^
  130. On arm64, the physical address size for a VM (IPA Size limit) is limited
  131. to 40bits by default. The limit can be configured if the host supports the
  132. extension KVM_CAP_ARM_VM_IPA_SIZE. When supported, use
  133. KVM_VM_TYPE_ARM_IPA_SIZE(IPA_Bits) to set the size in the machine type
  134. identifier, where IPA_Bits is the maximum width of any physical
  135. address used by the VM. The IPA_Bits is encoded in bits[7-0] of the
  136. machine type identifier.
  137. e.g, to configure a guest to use 48bit physical address size::
  138. vm_fd = ioctl(dev_fd, KVM_CREATE_VM, KVM_VM_TYPE_ARM_IPA_SIZE(48));
  139. The requested size (IPA_Bits) must be:
  140. == =========================================================
  141. 0 Implies default size, 40bits (for backward compatibility)
  142. N Implies N bits, where N is a positive integer such that,
  143. 32 <= N <= Host_IPA_Limit
  144. == =========================================================
  145. Host_IPA_Limit is the maximum possible value for IPA_Bits on the host and
  146. is dependent on the CPU capability and the kernel configuration. The limit can
  147. be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION
  148. ioctl() at run-time.
  149. Creation of the VM will fail if the requested IPA size (whether it is
  150. implicit or explicit) is unsupported on the host.
  151. Please note that configuring the IPA size does not affect the capability
  152. exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects
  153. size of the address translated by the stage2 level (guest physical to
  154. host physical address translations).
  155. 4.3 KVM_GET_MSR_INDEX_LIST, KVM_GET_MSR_FEATURE_INDEX_LIST
  156. ----------------------------------------------------------
  157. :Capability: basic, KVM_CAP_GET_MSR_FEATURES for KVM_GET_MSR_FEATURE_INDEX_LIST
  158. :Architectures: x86
  159. :Type: system ioctl
  160. :Parameters: struct kvm_msr_list (in/out)
  161. :Returns: 0 on success; -1 on error
  162. Errors:
  163. ====== ============================================================
  164. EFAULT the msr index list cannot be read from or written to
  165. E2BIG the msr index list is too big to fit in the array specified by
  166. the user.
  167. ====== ============================================================
  168. ::
  169. struct kvm_msr_list {
  170. __u32 nmsrs; /* number of msrs in entries */
  171. __u32 indices[0];
  172. };
  173. The user fills in the size of the indices array in nmsrs, and in return
  174. kvm adjusts nmsrs to reflect the actual number of msrs and fills in the
  175. indices array with their numbers.
  176. KVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list
  177. varies by kvm version and host processor, but does not change otherwise.
  178. Note: if kvm indicates supports MCE (KVM_CAP_MCE), then the MCE bank MSRs are
  179. not returned in the MSR list, as different vcpus can have a different number
  180. of banks, as set via the KVM_X86_SETUP_MCE ioctl.
  181. KVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed
  182. to the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities
  183. and processor features that are exposed via MSRs (e.g., VMX capabilities).
  184. This list also varies by kvm version and host processor, but does not change
  185. otherwise.
  186. 4.4 KVM_CHECK_EXTENSION
  187. -----------------------
  188. :Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl
  189. :Architectures: all
  190. :Type: system ioctl, vm ioctl
  191. :Parameters: extension identifier (KVM_CAP_*)
  192. :Returns: 0 if unsupported; 1 (or some other positive integer) if supported
  193. The API allows the application to query about extensions to the core
  194. kvm API. Userspace passes an extension identifier (an integer) and
  195. receives an integer that describes the extension availability.
  196. Generally 0 means no and 1 means yes, but some extensions may report
  197. additional information in the integer return value.
  198. Based on their initialization different VMs may have different capabilities.
  199. It is thus encouraged to use the vm ioctl to query for capabilities (available
  200. with KVM_CAP_CHECK_EXTENSION_VM on the vm fd)
  201. 4.5 KVM_GET_VCPU_MMAP_SIZE
  202. --------------------------
  203. :Capability: basic
  204. :Architectures: all
  205. :Type: system ioctl
  206. :Parameters: none
  207. :Returns: size of vcpu mmap area, in bytes
  208. The KVM_RUN ioctl (cf.) communicates with userspace via a shared
  209. memory region. This ioctl returns the size of that region. See the
  210. KVM_RUN documentation for details.
  211. Besides the size of the KVM_RUN communication region, other areas of
  212. the VCPU file descriptor can be mmap-ed, including:
  213. - if KVM_CAP_COALESCED_MMIO is available, a page at
  214. KVM_COALESCED_MMIO_PAGE_OFFSET * PAGE_SIZE; for historical reasons,
  215. this page is included in the result of KVM_GET_VCPU_MMAP_SIZE.
  216. KVM_CAP_COALESCED_MMIO is not documented yet.
  217. - if KVM_CAP_DIRTY_LOG_RING is available, a number of pages at
  218. KVM_DIRTY_LOG_PAGE_OFFSET * PAGE_SIZE. For more information on
  219. KVM_CAP_DIRTY_LOG_RING, see section 8.3.
  220. 4.7 KVM_CREATE_VCPU
  221. -------------------
  222. :Capability: basic
  223. :Architectures: all
  224. :Type: vm ioctl
  225. :Parameters: vcpu id (apic id on x86)
  226. :Returns: vcpu fd on success, -1 on error
  227. This API adds a vcpu to a virtual machine. No more than max_vcpus may be added.
  228. The vcpu id is an integer in the range [0, max_vcpu_id).
  229. The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of
  230. the KVM_CHECK_EXTENSION ioctl() at run-time.
  231. The maximum possible value for max_vcpus can be retrieved using the
  232. KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time.
  233. If the KVM_CAP_NR_VCPUS does not exist, you should assume that max_vcpus is 4
  234. cpus max.
  235. If the KVM_CAP_MAX_VCPUS does not exist, you should assume that max_vcpus is
  236. same as the value returned from KVM_CAP_NR_VCPUS.
  237. The maximum possible value for max_vcpu_id can be retrieved using the
  238. KVM_CAP_MAX_VCPU_ID of the KVM_CHECK_EXTENSION ioctl() at run-time.
  239. If the KVM_CAP_MAX_VCPU_ID does not exist, you should assume that max_vcpu_id
  240. is the same as the value returned from KVM_CAP_MAX_VCPUS.
  241. On powerpc using book3s_hv mode, the vcpus are mapped onto virtual
  242. threads in one or more virtual CPU cores. (This is because the
  243. hardware requires all the hardware threads in a CPU core to be in the
  244. same partition.) The KVM_CAP_PPC_SMT capability indicates the number
  245. of vcpus per virtual core (vcore). The vcore id is obtained by
  246. dividing the vcpu id by the number of vcpus per vcore. The vcpus in a
  247. given vcore will always be in the same physical core as each other
  248. (though that might be a different physical core from time to time).
  249. Userspace can control the threading (SMT) mode of the guest by its
  250. allocation of vcpu ids. For example, if userspace wants
  251. single-threaded guest vcpus, it should make all vcpu ids be a multiple
  252. of the number of vcpus per vcore.
  253. For virtual cpus that have been created with S390 user controlled virtual
  254. machines, the resulting vcpu fd can be memory mapped at page offset
  255. KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual
  256. cpu's hardware control block.
  257. 4.8 KVM_GET_DIRTY_LOG (vm ioctl)
  258. --------------------------------
  259. :Capability: basic
  260. :Architectures: all
  261. :Type: vm ioctl
  262. :Parameters: struct kvm_dirty_log (in/out)
  263. :Returns: 0 on success, -1 on error
  264. ::
  265. /* for KVM_GET_DIRTY_LOG */
  266. struct kvm_dirty_log {
  267. __u32 slot;
  268. __u32 padding;
  269. union {
  270. void __user *dirty_bitmap; /* one bit per page */
  271. __u64 padding;
  272. };
  273. };
  274. Given a memory slot, return a bitmap containing any pages dirtied
  275. since the last call to this ioctl. Bit 0 is the first page in the
  276. memory slot. Ensure the entire structure is cleared to avoid padding
  277. issues.
  278. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of slot field specifies
  279. the address space for which you want to return the dirty bitmap. See
  280. KVM_SET_USER_MEMORY_REGION for details on the usage of slot field.
  281. The bits in the dirty bitmap are cleared before the ioctl returns, unless
  282. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is enabled. For more information,
  283. see the description of the capability.
  284. Note that the Xen shared_info page, if configured, shall always be assumed
  285. to be dirty. KVM will not explicitly mark it such.
  286. 4.10 KVM_RUN
  287. ------------
  288. :Capability: basic
  289. :Architectures: all
  290. :Type: vcpu ioctl
  291. :Parameters: none
  292. :Returns: 0 on success, -1 on error
  293. Errors:
  294. ======= ==============================================================
  295. EINTR an unmasked signal is pending
  296. ENOEXEC the vcpu hasn't been initialized or the guest tried to execute
  297. instructions from device memory (arm64)
  298. ENOSYS data abort outside memslots with no syndrome info and
  299. KVM_CAP_ARM_NISV_TO_USER not enabled (arm64)
  300. EPERM SVE feature set but not finalized (arm64)
  301. ======= ==============================================================
  302. This ioctl is used to run a guest virtual cpu. While there are no
  303. explicit parameters, there is an implicit parameter block that can be
  304. obtained by mmap()ing the vcpu fd at offset 0, with the size given by
  305. KVM_GET_VCPU_MMAP_SIZE. The parameter block is formatted as a 'struct
  306. kvm_run' (see below).
  307. 4.11 KVM_GET_REGS
  308. -----------------
  309. :Capability: basic
  310. :Architectures: all except arm64
  311. :Type: vcpu ioctl
  312. :Parameters: struct kvm_regs (out)
  313. :Returns: 0 on success, -1 on error
  314. Reads the general purpose registers from the vcpu.
  315. ::
  316. /* x86 */
  317. struct kvm_regs {
  318. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  319. __u64 rax, rbx, rcx, rdx;
  320. __u64 rsi, rdi, rsp, rbp;
  321. __u64 r8, r9, r10, r11;
  322. __u64 r12, r13, r14, r15;
  323. __u64 rip, rflags;
  324. };
  325. /* mips */
  326. struct kvm_regs {
  327. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  328. __u64 gpr[32];
  329. __u64 hi;
  330. __u64 lo;
  331. __u64 pc;
  332. };
  333. /* LoongArch */
  334. struct kvm_regs {
  335. /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
  336. unsigned long gpr[32];
  337. unsigned long pc;
  338. };
  339. 4.12 KVM_SET_REGS
  340. -----------------
  341. :Capability: basic
  342. :Architectures: all except arm64
  343. :Type: vcpu ioctl
  344. :Parameters: struct kvm_regs (in)
  345. :Returns: 0 on success, -1 on error
  346. Writes the general purpose registers into the vcpu.
  347. See KVM_GET_REGS for the data structure.
  348. 4.13 KVM_GET_SREGS
  349. ------------------
  350. :Capability: basic
  351. :Architectures: x86, ppc
  352. :Type: vcpu ioctl
  353. :Parameters: struct kvm_sregs (out)
  354. :Returns: 0 on success, -1 on error
  355. Reads special registers from the vcpu.
  356. ::
  357. /* x86 */
  358. struct kvm_sregs {
  359. struct kvm_segment cs, ds, es, fs, gs, ss;
  360. struct kvm_segment tr, ldt;
  361. struct kvm_dtable gdt, idt;
  362. __u64 cr0, cr2, cr3, cr4, cr8;
  363. __u64 efer;
  364. __u64 apic_base;
  365. __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
  366. };
  367. /* ppc -- see arch/powerpc/include/uapi/asm/kvm.h */
  368. interrupt_bitmap is a bitmap of pending external interrupts. At most
  369. one bit may be set. This interrupt has been acknowledged by the APIC
  370. but not yet injected into the cpu core.
  371. 4.14 KVM_SET_SREGS
  372. ------------------
  373. :Capability: basic
  374. :Architectures: x86, ppc
  375. :Type: vcpu ioctl
  376. :Parameters: struct kvm_sregs (in)
  377. :Returns: 0 on success, -1 on error
  378. Writes special registers into the vcpu. See KVM_GET_SREGS for the
  379. data structures.
  380. 4.15 KVM_TRANSLATE
  381. ------------------
  382. :Capability: basic
  383. :Architectures: x86
  384. :Type: vcpu ioctl
  385. :Parameters: struct kvm_translation (in/out)
  386. :Returns: 0 on success, -1 on error
  387. Translates a virtual address according to the vcpu's current address
  388. translation mode.
  389. ::
  390. struct kvm_translation {
  391. /* in */
  392. __u64 linear_address;
  393. /* out */
  394. __u64 physical_address;
  395. __u8 valid;
  396. __u8 writeable;
  397. __u8 usermode;
  398. __u8 pad[5];
  399. };
  400. 4.16 KVM_INTERRUPT
  401. ------------------
  402. :Capability: basic
  403. :Architectures: x86, ppc, mips, riscv, loongarch
  404. :Type: vcpu ioctl
  405. :Parameters: struct kvm_interrupt (in)
  406. :Returns: 0 on success, negative on failure.
  407. Queues a hardware interrupt vector to be injected.
  408. ::
  409. /* for KVM_INTERRUPT */
  410. struct kvm_interrupt {
  411. /* in */
  412. __u32 irq;
  413. };
  414. X86:
  415. ^^^^
  416. :Returns:
  417. ========= ===================================
  418. 0 on success,
  419. -EEXIST if an interrupt is already enqueued
  420. -EINVAL the irq number is invalid
  421. -ENXIO if the PIC is in the kernel
  422. -EFAULT if the pointer is invalid
  423. ========= ===================================
  424. Note 'irq' is an interrupt vector, not an interrupt pin or line. This
  425. ioctl is useful if the in-kernel PIC is not used.
  426. PPC:
  427. ^^^^
  428. Queues an external interrupt to be injected. This ioctl is overloaded
  429. with 3 different irq values:
  430. a) KVM_INTERRUPT_SET
  431. This injects an edge type external interrupt into the guest once it's ready
  432. to receive interrupts. When injected, the interrupt is done.
  433. b) KVM_INTERRUPT_UNSET
  434. This unsets any pending interrupt.
  435. Only available with KVM_CAP_PPC_UNSET_IRQ.
  436. c) KVM_INTERRUPT_SET_LEVEL
  437. This injects a level type external interrupt into the guest context. The
  438. interrupt stays pending until a specific ioctl with KVM_INTERRUPT_UNSET
  439. is triggered.
  440. Only available with KVM_CAP_PPC_IRQ_LEVEL.
  441. Note that any value for 'irq' other than the ones stated above is invalid
  442. and incurs unexpected behavior.
  443. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  444. MIPS:
  445. ^^^^^
  446. Queues an external interrupt to be injected into the virtual CPU. A negative
  447. interrupt number dequeues the interrupt.
  448. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  449. RISC-V:
  450. ^^^^^^^
  451. Queues an external interrupt to be injected into the virtual CPU. This ioctl
  452. is overloaded with 2 different irq values:
  453. a) KVM_INTERRUPT_SET
  454. This sets external interrupt for a virtual CPU and it will receive
  455. once it is ready.
  456. b) KVM_INTERRUPT_UNSET
  457. This clears pending external interrupt for a virtual CPU.
  458. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  459. LOONGARCH:
  460. ^^^^^^^^^^
  461. Queues an external interrupt to be injected into the virtual CPU. A negative
  462. interrupt number dequeues the interrupt.
  463. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  464. 4.18 KVM_GET_MSRS
  465. -----------------
  466. :Capability: basic (vcpu), KVM_CAP_GET_MSR_FEATURES (system)
  467. :Architectures: x86
  468. :Type: system ioctl, vcpu ioctl
  469. :Parameters: struct kvm_msrs (in/out)
  470. :Returns: number of msrs successfully returned;
  471. -1 on error
  472. When used as a system ioctl:
  473. Reads the values of MSR-based features that are available for the VM. This
  474. is similar to KVM_GET_SUPPORTED_CPUID, but it returns MSR indices and values.
  475. The list of msr-based features can be obtained using KVM_GET_MSR_FEATURE_INDEX_LIST
  476. in a system ioctl.
  477. When used as a vcpu ioctl:
  478. Reads model-specific registers from the vcpu. Supported msr indices can
  479. be obtained using KVM_GET_MSR_INDEX_LIST in a system ioctl.
  480. ::
  481. struct kvm_msrs {
  482. __u32 nmsrs; /* number of msrs in entries */
  483. __u32 pad;
  484. struct kvm_msr_entry entries[0];
  485. };
  486. struct kvm_msr_entry {
  487. __u32 index;
  488. __u32 reserved;
  489. __u64 data;
  490. };
  491. Application code should set the 'nmsrs' member (which indicates the
  492. size of the entries array) and the 'index' member of each array entry.
  493. kvm will fill in the 'data' member.
  494. 4.19 KVM_SET_MSRS
  495. -----------------
  496. :Capability: basic
  497. :Architectures: x86
  498. :Type: vcpu ioctl
  499. :Parameters: struct kvm_msrs (in)
  500. :Returns: number of msrs successfully set (see below), -1 on error
  501. Writes model-specific registers to the vcpu. See KVM_GET_MSRS for the
  502. data structures.
  503. Application code should set the 'nmsrs' member (which indicates the
  504. size of the entries array), and the 'index' and 'data' members of each
  505. array entry.
  506. It tries to set the MSRs in array entries[] one by one. If setting an MSR
  507. fails, e.g., due to setting reserved bits, the MSR isn't supported/emulated
  508. by KVM, etc..., it stops processing the MSR list and returns the number of
  509. MSRs that have been set successfully.
  510. 4.20 KVM_SET_CPUID
  511. ------------------
  512. :Capability: basic
  513. :Architectures: x86
  514. :Type: vcpu ioctl
  515. :Parameters: struct kvm_cpuid (in)
  516. :Returns: 0 on success, -1 on error
  517. Defines the vcpu responses to the cpuid instruction. Applications
  518. should use the KVM_SET_CPUID2 ioctl if available.
  519. Caveat emptor:
  520. - If this IOCTL fails, KVM gives no guarantees that previous valid CPUID
  521. configuration (if there is) is not corrupted. Userspace can get a copy
  522. of the resulting CPUID configuration through KVM_GET_CPUID2 in case.
  523. - Using KVM_SET_CPUID{,2} after KVM_RUN, i.e. changing the guest vCPU model
  524. after running the guest, may cause guest instability.
  525. - Using heterogeneous CPUID configurations, modulo APIC IDs, topology, etc...
  526. may cause guest instability.
  527. ::
  528. struct kvm_cpuid_entry {
  529. __u32 function;
  530. __u32 eax;
  531. __u32 ebx;
  532. __u32 ecx;
  533. __u32 edx;
  534. __u32 padding;
  535. };
  536. /* for KVM_SET_CPUID */
  537. struct kvm_cpuid {
  538. __u32 nent;
  539. __u32 padding;
  540. struct kvm_cpuid_entry entries[0];
  541. };
  542. 4.21 KVM_SET_SIGNAL_MASK
  543. ------------------------
  544. :Capability: basic
  545. :Architectures: all
  546. :Type: vcpu ioctl
  547. :Parameters: struct kvm_signal_mask (in)
  548. :Returns: 0 on success, -1 on error
  549. Defines which signals are blocked during execution of KVM_RUN. This
  550. signal mask temporarily overrides the threads signal mask. Any
  551. unblocked signal received (except SIGKILL and SIGSTOP, which retain
  552. their traditional behaviour) will cause KVM_RUN to return with -EINTR.
  553. Note the signal will only be delivered if not blocked by the original
  554. signal mask.
  555. ::
  556. /* for KVM_SET_SIGNAL_MASK */
  557. struct kvm_signal_mask {
  558. __u32 len;
  559. __u8 sigset[0];
  560. };
  561. 4.22 KVM_GET_FPU
  562. ----------------
  563. :Capability: basic
  564. :Architectures: x86, loongarch
  565. :Type: vcpu ioctl
  566. :Parameters: struct kvm_fpu (out)
  567. :Returns: 0 on success, -1 on error
  568. Reads the floating point state from the vcpu.
  569. ::
  570. /* x86: for KVM_GET_FPU and KVM_SET_FPU */
  571. struct kvm_fpu {
  572. __u8 fpr[8][16];
  573. __u16 fcw;
  574. __u16 fsw;
  575. __u8 ftwx; /* in fxsave format */
  576. __u8 pad1;
  577. __u16 last_opcode;
  578. __u64 last_ip;
  579. __u64 last_dp;
  580. __u8 xmm[16][16];
  581. __u32 mxcsr;
  582. __u32 pad2;
  583. };
  584. /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */
  585. struct kvm_fpu {
  586. __u32 fcsr;
  587. __u64 fcc;
  588. struct kvm_fpureg {
  589. __u64 val64[4];
  590. }fpr[32];
  591. };
  592. 4.23 KVM_SET_FPU
  593. ----------------
  594. :Capability: basic
  595. :Architectures: x86, loongarch
  596. :Type: vcpu ioctl
  597. :Parameters: struct kvm_fpu (in)
  598. :Returns: 0 on success, -1 on error
  599. Writes the floating point state to the vcpu.
  600. ::
  601. /* x86: for KVM_GET_FPU and KVM_SET_FPU */
  602. struct kvm_fpu {
  603. __u8 fpr[8][16];
  604. __u16 fcw;
  605. __u16 fsw;
  606. __u8 ftwx; /* in fxsave format */
  607. __u8 pad1;
  608. __u16 last_opcode;
  609. __u64 last_ip;
  610. __u64 last_dp;
  611. __u8 xmm[16][16];
  612. __u32 mxcsr;
  613. __u32 pad2;
  614. };
  615. /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */
  616. struct kvm_fpu {
  617. __u32 fcsr;
  618. __u64 fcc;
  619. struct kvm_fpureg {
  620. __u64 val64[4];
  621. }fpr[32];
  622. };
  623. 4.24 KVM_CREATE_IRQCHIP
  624. -----------------------
  625. :Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390)
  626. :Architectures: x86, arm64, s390
  627. :Type: vm ioctl
  628. :Parameters: none
  629. :Returns: 0 on success, -1 on error
  630. Creates an interrupt controller model in the kernel.
  631. On x86, creates a virtual ioapic, a virtual PIC (two PICs, nested), and sets up
  632. future vcpus to have a local APIC. IRQ routing for GSIs 0-15 is set to both
  633. PIC and IOAPIC; GSI 16-23 only go to the IOAPIC.
  634. On arm64, a GICv2 is created. Any other GIC versions require the usage of
  635. KVM_CREATE_DEVICE, which also supports creating a GICv2. Using
  636. KVM_CREATE_DEVICE is preferred over KVM_CREATE_IRQCHIP for GICv2.
  637. On s390, a dummy irq routing table is created.
  638. Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled
  639. before KVM_CREATE_IRQCHIP can be used.
  640. 4.25 KVM_IRQ_LINE
  641. -----------------
  642. :Capability: KVM_CAP_IRQCHIP
  643. :Architectures: x86, arm64
  644. :Type: vm ioctl
  645. :Parameters: struct kvm_irq_level
  646. :Returns: 0 on success, -1 on error
  647. Sets the level of a GSI input to the interrupt controller model in the kernel.
  648. On some architectures it is required that an interrupt controller model has
  649. been previously created with KVM_CREATE_IRQCHIP. Note that edge-triggered
  650. interrupts require the level to be set to 1 and then back to 0.
  651. On real hardware, interrupt pins can be active-low or active-high. This
  652. does not matter for the level field of struct kvm_irq_level: 1 always
  653. means active (asserted), 0 means inactive (deasserted).
  654. x86 allows the operating system to program the interrupt polarity
  655. (active-low/active-high) for level-triggered interrupts, and KVM used
  656. to consider the polarity. However, due to bitrot in the handling of
  657. active-low interrupts, the above convention is now valid on x86 too.
  658. This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED. Userspace
  659. should not present interrupts to the guest as active-low unless this
  660. capability is present (or unless it is not using the in-kernel irqchip,
  661. of course).
  662. arm64 can signal an interrupt either at the CPU level, or at the
  663. in-kernel irqchip (GIC), and for in-kernel irqchip can tell the GIC to
  664. use PPIs designated for specific cpus. The irq field is interpreted
  665. like this::
  666. bits: | 31 ... 28 | 27 ... 24 | 23 ... 16 | 15 ... 0 |
  667. field: | vcpu2_index | irq_type | vcpu_index | irq_id |
  668. The irq_type field has the following values:
  669. - KVM_ARM_IRQ_TYPE_CPU:
  670. out-of-kernel GIC: irq_id 0 is IRQ, irq_id 1 is FIQ
  671. - KVM_ARM_IRQ_TYPE_SPI:
  672. in-kernel GIC: SPI, irq_id between 32 and 1019 (incl.)
  673. (the vcpu_index field is ignored)
  674. - KVM_ARM_IRQ_TYPE_PPI:
  675. in-kernel GIC: PPI, irq_id between 16 and 31 (incl.)
  676. (The irq_id field thus corresponds nicely to the IRQ ID in the ARM GIC specs)
  677. In both cases, level is used to assert/deassert the line.
  678. When KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 is supported, the target vcpu is
  679. identified as (256 * vcpu2_index + vcpu_index). Otherwise, vcpu2_index
  680. must be zero.
  681. Note that on arm64, the KVM_CAP_IRQCHIP capability only conditions
  682. injection of interrupts for the in-kernel irqchip. KVM_IRQ_LINE can always
  683. be used for a userspace interrupt controller.
  684. ::
  685. struct kvm_irq_level {
  686. union {
  687. __u32 irq; /* GSI */
  688. __s32 status; /* not used for KVM_IRQ_LEVEL */
  689. };
  690. __u32 level; /* 0 or 1 */
  691. };
  692. 4.26 KVM_GET_IRQCHIP
  693. --------------------
  694. :Capability: KVM_CAP_IRQCHIP
  695. :Architectures: x86
  696. :Type: vm ioctl
  697. :Parameters: struct kvm_irqchip (in/out)
  698. :Returns: 0 on success, -1 on error
  699. Reads the state of a kernel interrupt controller created with
  700. KVM_CREATE_IRQCHIP into a buffer provided by the caller.
  701. ::
  702. struct kvm_irqchip {
  703. __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
  704. __u32 pad;
  705. union {
  706. char dummy[512]; /* reserving space */
  707. struct kvm_pic_state pic;
  708. struct kvm_ioapic_state ioapic;
  709. } chip;
  710. };
  711. 4.27 KVM_SET_IRQCHIP
  712. --------------------
  713. :Capability: KVM_CAP_IRQCHIP
  714. :Architectures: x86
  715. :Type: vm ioctl
  716. :Parameters: struct kvm_irqchip (in)
  717. :Returns: 0 on success, -1 on error
  718. Sets the state of a kernel interrupt controller created with
  719. KVM_CREATE_IRQCHIP from a buffer provided by the caller.
  720. ::
  721. struct kvm_irqchip {
  722. __u32 chip_id; /* 0 = PIC1, 1 = PIC2, 2 = IOAPIC */
  723. __u32 pad;
  724. union {
  725. char dummy[512]; /* reserving space */
  726. struct kvm_pic_state pic;
  727. struct kvm_ioapic_state ioapic;
  728. } chip;
  729. };
  730. 4.28 KVM_XEN_HVM_CONFIG
  731. -----------------------
  732. :Capability: KVM_CAP_XEN_HVM
  733. :Architectures: x86
  734. :Type: vm ioctl
  735. :Parameters: struct kvm_xen_hvm_config (in)
  736. :Returns: 0 on success, -1 on error
  737. Sets the MSR that the Xen HVM guest uses to initialize its hypercall
  738. page, and provides the starting address and size of the hypercall
  739. blobs in userspace. When the guest writes the MSR, kvm copies one
  740. page of a blob (32- or 64-bit, depending on the vcpu mode) to guest
  741. memory.
  742. ::
  743. struct kvm_xen_hvm_config {
  744. __u32 flags;
  745. __u32 msr;
  746. __u64 blob_addr_32;
  747. __u64 blob_addr_64;
  748. __u8 blob_size_32;
  749. __u8 blob_size_64;
  750. __u8 pad2[30];
  751. };
  752. If certain flags are returned from the KVM_CAP_XEN_HVM check, they may
  753. be set in the flags field of this ioctl:
  754. The KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL flag requests KVM to generate
  755. the contents of the hypercall page automatically; hypercalls will be
  756. intercepted and passed to userspace through KVM_EXIT_XEN. In this
  757. case, all of the blob size and address fields must be zero.
  758. The KVM_XEN_HVM_CONFIG_EVTCHN_SEND flag indicates to KVM that userspace
  759. will always use the KVM_XEN_HVM_EVTCHN_SEND ioctl to deliver event
  760. channel interrupts rather than manipulating the guest's shared_info
  761. structures directly. This, in turn, may allow KVM to enable features
  762. such as intercepting the SCHEDOP_poll hypercall to accelerate PV
  763. spinlock operation for the guest. Userspace may still use the ioctl
  764. to deliver events if it was advertised, even if userspace does not
  765. send this indication that it will always do so
  766. No other flags are currently valid in the struct kvm_xen_hvm_config.
  767. 4.29 KVM_GET_CLOCK
  768. ------------------
  769. :Capability: KVM_CAP_ADJUST_CLOCK
  770. :Architectures: x86
  771. :Type: vm ioctl
  772. :Parameters: struct kvm_clock_data (out)
  773. :Returns: 0 on success, -1 on error
  774. Gets the current timestamp of kvmclock as seen by the current guest. In
  775. conjunction with KVM_SET_CLOCK, it is used to ensure monotonicity on scenarios
  776. such as migration.
  777. When KVM_CAP_ADJUST_CLOCK is passed to KVM_CHECK_EXTENSION, it returns the
  778. set of bits that KVM can return in struct kvm_clock_data's flag member.
  779. The following flags are defined:
  780. KVM_CLOCK_TSC_STABLE
  781. If set, the returned value is the exact kvmclock
  782. value seen by all VCPUs at the instant when KVM_GET_CLOCK was called.
  783. If clear, the returned value is simply CLOCK_MONOTONIC plus a constant
  784. offset; the offset can be modified with KVM_SET_CLOCK. KVM will try
  785. to make all VCPUs follow this clock, but the exact value read by each
  786. VCPU could differ, because the host TSC is not stable.
  787. KVM_CLOCK_REALTIME
  788. If set, the `realtime` field in the kvm_clock_data
  789. structure is populated with the value of the host's real time
  790. clocksource at the instant when KVM_GET_CLOCK was called. If clear,
  791. the `realtime` field does not contain a value.
  792. KVM_CLOCK_HOST_TSC
  793. If set, the `host_tsc` field in the kvm_clock_data
  794. structure is populated with the value of the host's timestamp counter (TSC)
  795. at the instant when KVM_GET_CLOCK was called. If clear, the `host_tsc` field
  796. does not contain a value.
  797. ::
  798. struct kvm_clock_data {
  799. __u64 clock; /* kvmclock current value */
  800. __u32 flags;
  801. __u32 pad0;
  802. __u64 realtime;
  803. __u64 host_tsc;
  804. __u32 pad[4];
  805. };
  806. 4.30 KVM_SET_CLOCK
  807. ------------------
  808. :Capability: KVM_CAP_ADJUST_CLOCK
  809. :Architectures: x86
  810. :Type: vm ioctl
  811. :Parameters: struct kvm_clock_data (in)
  812. :Returns: 0 on success, -1 on error
  813. Sets the current timestamp of kvmclock to the value specified in its parameter.
  814. In conjunction with KVM_GET_CLOCK, it is used to ensure monotonicity on scenarios
  815. such as migration.
  816. The following flags can be passed:
  817. KVM_CLOCK_REALTIME
  818. If set, KVM will compare the value of the `realtime` field
  819. with the value of the host's real time clocksource at the instant when
  820. KVM_SET_CLOCK was called. The difference in elapsed time is added to the final
  821. kvmclock value that will be provided to guests.
  822. Other flags returned by ``KVM_GET_CLOCK`` are accepted but ignored.
  823. ::
  824. struct kvm_clock_data {
  825. __u64 clock; /* kvmclock current value */
  826. __u32 flags;
  827. __u32 pad0;
  828. __u64 realtime;
  829. __u64 host_tsc;
  830. __u32 pad[4];
  831. };
  832. 4.31 KVM_GET_VCPU_EVENTS
  833. ------------------------
  834. :Capability: KVM_CAP_VCPU_EVENTS
  835. :Extended by: KVM_CAP_INTR_SHADOW
  836. :Architectures: x86, arm64
  837. :Type: vcpu ioctl
  838. :Parameters: struct kvm_vcpu_events (out)
  839. :Returns: 0 on success, -1 on error
  840. X86:
  841. ^^^^
  842. Gets currently pending exceptions, interrupts, and NMIs as well as related
  843. states of the vcpu.
  844. ::
  845. struct kvm_vcpu_events {
  846. struct {
  847. __u8 injected;
  848. __u8 nr;
  849. __u8 has_error_code;
  850. __u8 pending;
  851. __u32 error_code;
  852. } exception;
  853. struct {
  854. __u8 injected;
  855. __u8 nr;
  856. __u8 soft;
  857. __u8 shadow;
  858. } interrupt;
  859. struct {
  860. __u8 injected;
  861. __u8 pending;
  862. __u8 masked;
  863. __u8 pad;
  864. } nmi;
  865. __u32 sipi_vector;
  866. __u32 flags;
  867. struct {
  868. __u8 smm;
  869. __u8 pending;
  870. __u8 smm_inside_nmi;
  871. __u8 latched_init;
  872. } smi;
  873. __u8 reserved[27];
  874. __u8 exception_has_payload;
  875. __u64 exception_payload;
  876. };
  877. The following bits are defined in the flags field:
  878. - KVM_VCPUEVENT_VALID_SHADOW may be set to signal that
  879. interrupt.shadow contains a valid state.
  880. - KVM_VCPUEVENT_VALID_SMM may be set to signal that smi contains a
  881. valid state.
  882. - KVM_VCPUEVENT_VALID_PAYLOAD may be set to signal that the
  883. exception_has_payload, exception_payload, and exception.pending
  884. fields contain a valid state. This bit will be set whenever
  885. KVM_CAP_EXCEPTION_PAYLOAD is enabled.
  886. - KVM_VCPUEVENT_VALID_TRIPLE_FAULT may be set to signal that the
  887. triple_fault_pending field contains a valid state. This bit will
  888. be set whenever KVM_CAP_X86_TRIPLE_FAULT_EVENT is enabled.
  889. ARM64:
  890. ^^^^^^
  891. If the guest accesses a device that is being emulated by the host kernel in
  892. such a way that a real device would generate a physical SError, KVM may make
  893. a virtual SError pending for that VCPU. This system error interrupt remains
  894. pending until the guest takes the exception by unmasking PSTATE.A.
  895. Running the VCPU may cause it to take a pending SError, or make an access that
  896. causes an SError to become pending. The event's description is only valid while
  897. the VPCU is not running.
  898. This API provides a way to read and write the pending 'event' state that is not
  899. visible to the guest. To save, restore or migrate a VCPU the struct representing
  900. the state can be read then written using this GET/SET API, along with the other
  901. guest-visible registers. It is not possible to 'cancel' an SError that has been
  902. made pending.
  903. A device being emulated in user-space may also wish to generate an SError. To do
  904. this the events structure can be populated by user-space. The current state
  905. should be read first, to ensure no existing SError is pending. If an existing
  906. SError is pending, the architecture's 'Multiple SError interrupts' rules should
  907. be followed. (2.5.3 of DDI0587.a "ARM Reliability, Availability, and
  908. Serviceability (RAS) Specification").
  909. SError exceptions always have an ESR value. Some CPUs have the ability to
  910. specify what the virtual SError's ESR value should be. These systems will
  911. advertise KVM_CAP_ARM_INJECT_SERROR_ESR. In this case exception.has_esr will
  912. always have a non-zero value when read, and the agent making an SError pending
  913. should specify the ISS field in the lower 24 bits of exception.serror_esr. If
  914. the system supports KVM_CAP_ARM_INJECT_SERROR_ESR, but user-space sets the events
  915. with exception.has_esr as zero, KVM will choose an ESR.
  916. Specifying exception.has_esr on a system that does not support it will return
  917. -EINVAL. Setting anything other than the lower 24bits of exception.serror_esr
  918. will return -EINVAL.
  919. It is not possible to read back a pending external abort (injected via
  920. KVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered
  921. directly to the virtual CPU).
  922. ::
  923. struct kvm_vcpu_events {
  924. struct {
  925. __u8 serror_pending;
  926. __u8 serror_has_esr;
  927. __u8 ext_dabt_pending;
  928. /* Align it to 8 bytes */
  929. __u8 pad[5];
  930. __u64 serror_esr;
  931. } exception;
  932. __u32 reserved[12];
  933. };
  934. 4.32 KVM_SET_VCPU_EVENTS
  935. ------------------------
  936. :Capability: KVM_CAP_VCPU_EVENTS
  937. :Extended by: KVM_CAP_INTR_SHADOW
  938. :Architectures: x86, arm64
  939. :Type: vcpu ioctl
  940. :Parameters: struct kvm_vcpu_events (in)
  941. :Returns: 0 on success, -1 on error
  942. X86:
  943. ^^^^
  944. Set pending exceptions, interrupts, and NMIs as well as related states of the
  945. vcpu.
  946. See KVM_GET_VCPU_EVENTS for the data structure.
  947. Fields that may be modified asynchronously by running VCPUs can be excluded
  948. from the update. These fields are nmi.pending, sipi_vector, smi.smm,
  949. smi.pending. Keep the corresponding bits in the flags field cleared to
  950. suppress overwriting the current in-kernel state. The bits are:
  951. =============================== ==================================
  952. KVM_VCPUEVENT_VALID_NMI_PENDING transfer nmi.pending to the kernel
  953. KVM_VCPUEVENT_VALID_SIPI_VECTOR transfer sipi_vector
  954. KVM_VCPUEVENT_VALID_SMM transfer the smi sub-struct.
  955. =============================== ==================================
  956. If KVM_CAP_INTR_SHADOW is available, KVM_VCPUEVENT_VALID_SHADOW can be set in
  957. the flags field to signal that interrupt.shadow contains a valid state and
  958. shall be written into the VCPU.
  959. KVM_VCPUEVENT_VALID_SMM can only be set if KVM_CAP_X86_SMM is available.
  960. If KVM_CAP_EXCEPTION_PAYLOAD is enabled, KVM_VCPUEVENT_VALID_PAYLOAD
  961. can be set in the flags field to signal that the
  962. exception_has_payload, exception_payload, and exception.pending fields
  963. contain a valid state and shall be written into the VCPU.
  964. If KVM_CAP_X86_TRIPLE_FAULT_EVENT is enabled, KVM_VCPUEVENT_VALID_TRIPLE_FAULT
  965. can be set in flags field to signal that the triple_fault field contains
  966. a valid state and shall be written into the VCPU.
  967. ARM64:
  968. ^^^^^^
  969. User space may need to inject several types of events to the guest.
  970. Set the pending SError exception state for this VCPU. It is not possible to
  971. 'cancel' an Serror that has been made pending.
  972. If the guest performed an access to I/O memory which could not be handled by
  973. userspace, for example because of missing instruction syndrome decode
  974. information or because there is no device mapped at the accessed IPA, then
  975. userspace can ask the kernel to inject an external abort using the address
  976. from the exiting fault on the VCPU. It is a programming error to set
  977. ext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or
  978. KVM_EXIT_ARM_NISV. This feature is only available if the system supports
  979. KVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in
  980. how userspace reports accesses for the above cases to guests, across different
  981. userspace implementations. Nevertheless, userspace can still emulate all Arm
  982. exceptions by manipulating individual registers using the KVM_SET_ONE_REG API.
  983. See KVM_GET_VCPU_EVENTS for the data structure.
  984. 4.33 KVM_GET_DEBUGREGS
  985. ----------------------
  986. :Capability: KVM_CAP_DEBUGREGS
  987. :Architectures: x86
  988. :Type: vm ioctl
  989. :Parameters: struct kvm_debugregs (out)
  990. :Returns: 0 on success, -1 on error
  991. Reads debug registers from the vcpu.
  992. ::
  993. struct kvm_debugregs {
  994. __u64 db[4];
  995. __u64 dr6;
  996. __u64 dr7;
  997. __u64 flags;
  998. __u64 reserved[9];
  999. };
  1000. 4.34 KVM_SET_DEBUGREGS
  1001. ----------------------
  1002. :Capability: KVM_CAP_DEBUGREGS
  1003. :Architectures: x86
  1004. :Type: vm ioctl
  1005. :Parameters: struct kvm_debugregs (in)
  1006. :Returns: 0 on success, -1 on error
  1007. Writes debug registers into the vcpu.
  1008. See KVM_GET_DEBUGREGS for the data structure. The flags field is unused
  1009. yet and must be cleared on entry.
  1010. 4.35 KVM_SET_USER_MEMORY_REGION
  1011. -------------------------------
  1012. :Capability: KVM_CAP_USER_MEMORY
  1013. :Architectures: all
  1014. :Type: vm ioctl
  1015. :Parameters: struct kvm_userspace_memory_region (in)
  1016. :Returns: 0 on success, -1 on error
  1017. ::
  1018. struct kvm_userspace_memory_region {
  1019. __u32 slot;
  1020. __u32 flags;
  1021. __u64 guest_phys_addr;
  1022. __u64 memory_size; /* bytes */
  1023. __u64 userspace_addr; /* start of the userspace allocated memory */
  1024. };
  1025. /* for kvm_userspace_memory_region::flags */
  1026. #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
  1027. #define KVM_MEM_READONLY (1UL << 1)
  1028. This ioctl allows the user to create, modify or delete a guest physical
  1029. memory slot. Bits 0-15 of "slot" specify the slot id and this value
  1030. should be less than the maximum number of user memory slots supported per
  1031. VM. The maximum allowed slots can be queried using KVM_CAP_NR_MEMSLOTS.
  1032. Slots may not overlap in guest physical address space.
  1033. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of "slot"
  1034. specifies the address space which is being modified. They must be
  1035. less than the value that KVM_CHECK_EXTENSION returns for the
  1036. KVM_CAP_MULTI_ADDRESS_SPACE capability. Slots in separate address spaces
  1037. are unrelated; the restriction on overlapping slots only applies within
  1038. each address space.
  1039. Deleting a slot is done by passing zero for memory_size. When changing
  1040. an existing slot, it may be moved in the guest physical memory space,
  1041. or its flags may be modified, but it may not be resized.
  1042. Memory for the region is taken starting at the address denoted by the
  1043. field userspace_addr, which must point at user addressable memory for
  1044. the entire memory slot size. Any object may back this memory, including
  1045. anonymous memory, ordinary files, and hugetlbfs.
  1046. On architectures that support a form of address tagging, userspace_addr must
  1047. be an untagged address.
  1048. It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
  1049. be identical. This allows large pages in the guest to be backed by large
  1050. pages in the host.
  1051. The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and
  1052. KVM_MEM_READONLY. The former can be set to instruct KVM to keep track of
  1053. writes to memory within the slot. See KVM_GET_DIRTY_LOG ioctl to know how to
  1054. use it. The latter can be set, if KVM_CAP_READONLY_MEM capability allows it,
  1055. to make a new slot read-only. In this case, writes to this memory will be
  1056. posted to userspace as KVM_EXIT_MMIO exits.
  1057. When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of
  1058. the memory region are automatically reflected into the guest. For example, an
  1059. mmap() that affects the region will be made visible immediately. Another
  1060. example is madvise(MADV_DROP).
  1061. Note: On arm64, a write generated by the page-table walker (to update
  1062. the Access and Dirty flags, for example) never results in a
  1063. KVM_EXIT_MMIO exit when the slot has the KVM_MEM_READONLY flag. This
  1064. is because KVM cannot provide the data that would be written by the
  1065. page-table walker, making it impossible to emulate the access.
  1066. Instead, an abort (data abort if the cause of the page-table update
  1067. was a load or a store, instruction abort if it was an instruction
  1068. fetch) is injected in the guest.
  1069. S390:
  1070. ^^^^^
  1071. Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
  1072. Returns -EINVAL if called on a protected VM.
  1073. 4.36 KVM_SET_TSS_ADDR
  1074. ---------------------
  1075. :Capability: KVM_CAP_SET_TSS_ADDR
  1076. :Architectures: x86
  1077. :Type: vm ioctl
  1078. :Parameters: unsigned long tss_address (in)
  1079. :Returns: 0 on success, -1 on error
  1080. This ioctl defines the physical address of a three-page region in the guest
  1081. physical address space. The region must be within the first 4GB of the
  1082. guest physical address space and must not conflict with any memory slot
  1083. or any mmio address. The guest may malfunction if it accesses this memory
  1084. region.
  1085. This ioctl is required on Intel-based hosts. This is needed on Intel hardware
  1086. because of a quirk in the virtualization implementation (see the internals
  1087. documentation when it pops into existence).
  1088. 4.37 KVM_ENABLE_CAP
  1089. -------------------
  1090. :Capability: KVM_CAP_ENABLE_CAP
  1091. :Architectures: mips, ppc, s390, x86, loongarch
  1092. :Type: vcpu ioctl
  1093. :Parameters: struct kvm_enable_cap (in)
  1094. :Returns: 0 on success; -1 on error
  1095. :Capability: KVM_CAP_ENABLE_CAP_VM
  1096. :Architectures: all
  1097. :Type: vm ioctl
  1098. :Parameters: struct kvm_enable_cap (in)
  1099. :Returns: 0 on success; -1 on error
  1100. .. note::
  1101. Not all extensions are enabled by default. Using this ioctl the application
  1102. can enable an extension, making it available to the guest.
  1103. On systems that do not support this ioctl, it always fails. On systems that
  1104. do support it, it only works for extensions that are supported for enablement.
  1105. To check if a capability can be enabled, the KVM_CHECK_EXTENSION ioctl should
  1106. be used.
  1107. ::
  1108. struct kvm_enable_cap {
  1109. /* in */
  1110. __u32 cap;
  1111. The capability that is supposed to get enabled.
  1112. ::
  1113. __u32 flags;
  1114. A bitfield indicating future enhancements. Has to be 0 for now.
  1115. ::
  1116. __u64 args[4];
  1117. Arguments for enabling a feature. If a feature needs initial values to
  1118. function properly, this is the place to put them.
  1119. ::
  1120. __u8 pad[64];
  1121. };
  1122. The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl
  1123. for vm-wide capabilities.
  1124. 4.38 KVM_GET_MP_STATE
  1125. ---------------------
  1126. :Capability: KVM_CAP_MP_STATE
  1127. :Architectures: x86, s390, arm64, riscv, loongarch
  1128. :Type: vcpu ioctl
  1129. :Parameters: struct kvm_mp_state (out)
  1130. :Returns: 0 on success; -1 on error
  1131. ::
  1132. struct kvm_mp_state {
  1133. __u32 mp_state;
  1134. };
  1135. Returns the vcpu's current "multiprocessing state" (though also valid on
  1136. uniprocessor guests).
  1137. Possible values are:
  1138. ========================== ===============================================
  1139. KVM_MP_STATE_RUNNABLE the vcpu is currently running
  1140. [x86,arm64,riscv,loongarch]
  1141. KVM_MP_STATE_UNINITIALIZED the vcpu is an application processor (AP)
  1142. which has not yet received an INIT signal [x86]
  1143. KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, and is
  1144. now ready for a SIPI [x86]
  1145. KVM_MP_STATE_HALTED the vcpu has executed a HLT instruction and
  1146. is waiting for an interrupt [x86]
  1147. KVM_MP_STATE_SIPI_RECEIVED the vcpu has just received a SIPI (vector
  1148. accessible via KVM_GET_VCPU_EVENTS) [x86]
  1149. KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm64,riscv]
  1150. KVM_MP_STATE_CHECK_STOP the vcpu is in a special error state [s390]
  1151. KVM_MP_STATE_OPERATING the vcpu is operating (running or halted)
  1152. [s390]
  1153. KVM_MP_STATE_LOAD the vcpu is in a special load/startup state
  1154. [s390]
  1155. KVM_MP_STATE_SUSPENDED the vcpu is in a suspend state and is waiting
  1156. for a wakeup event [arm64]
  1157. ========================== ===============================================
  1158. On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
  1159. in-kernel irqchip, the multiprocessing state must be maintained by userspace on
  1160. these architectures.
  1161. For arm64:
  1162. ^^^^^^^^^^
  1163. If a vCPU is in the KVM_MP_STATE_SUSPENDED state, KVM will emulate the
  1164. architectural execution of a WFI instruction.
  1165. If a wakeup event is recognized, KVM will exit to userspace with a
  1166. KVM_SYSTEM_EVENT exit, where the event type is KVM_SYSTEM_EVENT_WAKEUP. If
  1167. userspace wants to honor the wakeup, it must set the vCPU's MP state to
  1168. KVM_MP_STATE_RUNNABLE. If it does not, KVM will continue to await a wakeup
  1169. event in subsequent calls to KVM_RUN.
  1170. .. warning::
  1171. If userspace intends to keep the vCPU in a SUSPENDED state, it is
  1172. strongly recommended that userspace take action to suppress the
  1173. wakeup event (such as masking an interrupt). Otherwise, subsequent
  1174. calls to KVM_RUN will immediately exit with a KVM_SYSTEM_EVENT_WAKEUP
  1175. event and inadvertently waste CPU cycles.
  1176. Additionally, if userspace takes action to suppress a wakeup event,
  1177. it is strongly recommended that it also restores the vCPU to its
  1178. original state when the vCPU is made RUNNABLE again. For example,
  1179. if userspace masked a pending interrupt to suppress the wakeup,
  1180. the interrupt should be unmasked before returning control to the
  1181. guest.
  1182. For riscv:
  1183. ^^^^^^^^^^
  1184. The only states that are valid are KVM_MP_STATE_STOPPED and
  1185. KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not.
  1186. On LoongArch, only the KVM_MP_STATE_RUNNABLE state is used to reflect
  1187. whether the vcpu is runnable.
  1188. 4.39 KVM_SET_MP_STATE
  1189. ---------------------
  1190. :Capability: KVM_CAP_MP_STATE
  1191. :Architectures: x86, s390, arm64, riscv, loongarch
  1192. :Type: vcpu ioctl
  1193. :Parameters: struct kvm_mp_state (in)
  1194. :Returns: 0 on success; -1 on error
  1195. Sets the vcpu's current "multiprocessing state"; see KVM_GET_MP_STATE for
  1196. arguments.
  1197. On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an
  1198. in-kernel irqchip, the multiprocessing state must be maintained by userspace on
  1199. these architectures.
  1200. For arm64/riscv:
  1201. ^^^^^^^^^^^^^^^^
  1202. The only states that are valid are KVM_MP_STATE_STOPPED and
  1203. KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not.
  1204. On LoongArch, only the KVM_MP_STATE_RUNNABLE state is used to reflect
  1205. whether the vcpu is runnable.
  1206. 4.40 KVM_SET_IDENTITY_MAP_ADDR
  1207. ------------------------------
  1208. :Capability: KVM_CAP_SET_IDENTITY_MAP_ADDR
  1209. :Architectures: x86
  1210. :Type: vm ioctl
  1211. :Parameters: unsigned long identity (in)
  1212. :Returns: 0 on success, -1 on error
  1213. This ioctl defines the physical address of a one-page region in the guest
  1214. physical address space. The region must be within the first 4GB of the
  1215. guest physical address space and must not conflict with any memory slot
  1216. or any mmio address. The guest may malfunction if it accesses this memory
  1217. region.
  1218. Setting the address to 0 will result in resetting the address to its default
  1219. (0xfffbc000).
  1220. This ioctl is required on Intel-based hosts. This is needed on Intel hardware
  1221. because of a quirk in the virtualization implementation (see the internals
  1222. documentation when it pops into existence).
  1223. Fails if any VCPU has already been created.
  1224. 4.41 KVM_SET_BOOT_CPU_ID
  1225. ------------------------
  1226. :Capability: KVM_CAP_SET_BOOT_CPU_ID
  1227. :Architectures: x86
  1228. :Type: vm ioctl
  1229. :Parameters: unsigned long vcpu_id
  1230. :Returns: 0 on success, -1 on error
  1231. Define which vcpu is the Bootstrap Processor (BSP). Values are the same
  1232. as the vcpu id in KVM_CREATE_VCPU. If this ioctl is not called, the default
  1233. is vcpu 0. This ioctl has to be called before vcpu creation,
  1234. otherwise it will return EBUSY error.
  1235. 4.42 KVM_GET_XSAVE
  1236. ------------------
  1237. :Capability: KVM_CAP_XSAVE
  1238. :Architectures: x86
  1239. :Type: vcpu ioctl
  1240. :Parameters: struct kvm_xsave (out)
  1241. :Returns: 0 on success, -1 on error
  1242. ::
  1243. struct kvm_xsave {
  1244. __u32 region[1024];
  1245. __u32 extra[0];
  1246. };
  1247. This ioctl would copy current vcpu's xsave struct to the userspace.
  1248. 4.43 KVM_SET_XSAVE
  1249. ------------------
  1250. :Capability: KVM_CAP_XSAVE and KVM_CAP_XSAVE2
  1251. :Architectures: x86
  1252. :Type: vcpu ioctl
  1253. :Parameters: struct kvm_xsave (in)
  1254. :Returns: 0 on success, -1 on error
  1255. ::
  1256. struct kvm_xsave {
  1257. __u32 region[1024];
  1258. __u32 extra[0];
  1259. };
  1260. This ioctl would copy userspace's xsave struct to the kernel. It copies
  1261. as many bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2),
  1262. when invoked on the vm file descriptor. The size value returned by
  1263. KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will always be at least 4096.
  1264. Currently, it is only greater than 4096 if a dynamic feature has been
  1265. enabled with ``arch_prctl()``, but this may change in the future.
  1266. The offsets of the state save areas in struct kvm_xsave follow the
  1267. contents of CPUID leaf 0xD on the host.
  1268. 4.44 KVM_GET_XCRS
  1269. -----------------
  1270. :Capability: KVM_CAP_XCRS
  1271. :Architectures: x86
  1272. :Type: vcpu ioctl
  1273. :Parameters: struct kvm_xcrs (out)
  1274. :Returns: 0 on success, -1 on error
  1275. ::
  1276. struct kvm_xcr {
  1277. __u32 xcr;
  1278. __u32 reserved;
  1279. __u64 value;
  1280. };
  1281. struct kvm_xcrs {
  1282. __u32 nr_xcrs;
  1283. __u32 flags;
  1284. struct kvm_xcr xcrs[KVM_MAX_XCRS];
  1285. __u64 padding[16];
  1286. };
  1287. This ioctl would copy current vcpu's xcrs to the userspace.
  1288. 4.45 KVM_SET_XCRS
  1289. -----------------
  1290. :Capability: KVM_CAP_XCRS
  1291. :Architectures: x86
  1292. :Type: vcpu ioctl
  1293. :Parameters: struct kvm_xcrs (in)
  1294. :Returns: 0 on success, -1 on error
  1295. ::
  1296. struct kvm_xcr {
  1297. __u32 xcr;
  1298. __u32 reserved;
  1299. __u64 value;
  1300. };
  1301. struct kvm_xcrs {
  1302. __u32 nr_xcrs;
  1303. __u32 flags;
  1304. struct kvm_xcr xcrs[KVM_MAX_XCRS];
  1305. __u64 padding[16];
  1306. };
  1307. This ioctl would set vcpu's xcr to the value userspace specified.
  1308. 4.46 KVM_GET_SUPPORTED_CPUID
  1309. ----------------------------
  1310. :Capability: KVM_CAP_EXT_CPUID
  1311. :Architectures: x86
  1312. :Type: system ioctl
  1313. :Parameters: struct kvm_cpuid2 (in/out)
  1314. :Returns: 0 on success, -1 on error
  1315. ::
  1316. struct kvm_cpuid2 {
  1317. __u32 nent;
  1318. __u32 padding;
  1319. struct kvm_cpuid_entry2 entries[0];
  1320. };
  1321. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  1322. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */
  1323. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */
  1324. struct kvm_cpuid_entry2 {
  1325. __u32 function;
  1326. __u32 index;
  1327. __u32 flags;
  1328. __u32 eax;
  1329. __u32 ebx;
  1330. __u32 ecx;
  1331. __u32 edx;
  1332. __u32 padding[3];
  1333. };
  1334. This ioctl returns x86 cpuid features which are supported by both the
  1335. hardware and kvm in its default configuration. Userspace can use the
  1336. information returned by this ioctl to construct cpuid information (for
  1337. KVM_SET_CPUID2) that is consistent with hardware, kernel, and
  1338. userspace capabilities, and with user requirements (for example, the
  1339. user may wish to constrain cpuid to emulate older hardware, or for
  1340. feature consistency across a cluster).
  1341. Dynamically-enabled feature bits need to be requested with
  1342. ``arch_prctl()`` before calling this ioctl. Feature bits that have not
  1343. been requested are excluded from the result.
  1344. Note that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may
  1345. expose cpuid features (e.g. MONITOR) which are not supported by kvm in
  1346. its default configuration. If userspace enables such capabilities, it
  1347. is responsible for modifying the results of this ioctl appropriately.
  1348. Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure
  1349. with the 'nent' field indicating the number of entries in the variable-size
  1350. array 'entries'. If the number of entries is too low to describe the cpu
  1351. capabilities, an error (E2BIG) is returned. If the number is too high,
  1352. the 'nent' field is adjusted and an error (ENOMEM) is returned. If the
  1353. number is just right, the 'nent' field is adjusted to the number of valid
  1354. entries in the 'entries' array, which is then filled.
  1355. The entries returned are the host cpuid as returned by the cpuid instruction,
  1356. with unknown or unsupported features masked out. Some features (for example,
  1357. x2apic), may not be present in the host cpu, but are exposed by kvm if it can
  1358. emulate them efficiently. The fields in each entry are defined as follows:
  1359. function:
  1360. the eax value used to obtain the entry
  1361. index:
  1362. the ecx value used to obtain the entry (for entries that are
  1363. affected by ecx)
  1364. flags:
  1365. an OR of zero or more of the following:
  1366. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  1367. if the index field is valid
  1368. eax, ebx, ecx, edx:
  1369. the values returned by the cpuid instruction for
  1370. this function/index combination
  1371. The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
  1372. as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
  1373. support. Instead it is reported via::
  1374. ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
  1375. if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the
  1376. feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
  1377. 4.47 KVM_PPC_GET_PVINFO
  1378. -----------------------
  1379. :Capability: KVM_CAP_PPC_GET_PVINFO
  1380. :Architectures: ppc
  1381. :Type: vm ioctl
  1382. :Parameters: struct kvm_ppc_pvinfo (out)
  1383. :Returns: 0 on success, !0 on error
  1384. ::
  1385. struct kvm_ppc_pvinfo {
  1386. __u32 flags;
  1387. __u32 hcall[4];
  1388. __u8 pad[108];
  1389. };
  1390. This ioctl fetches PV specific information that need to be passed to the guest
  1391. using the device tree or other means from vm context.
  1392. The hcall array defines 4 instructions that make up a hypercall.
  1393. If any additional field gets added to this structure later on, a bit for that
  1394. additional piece of information will be set in the flags bitmap.
  1395. The flags bitmap is defined as::
  1396. /* the host supports the ePAPR idle hcall
  1397. #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)
  1398. 4.52 KVM_SET_GSI_ROUTING
  1399. ------------------------
  1400. :Capability: KVM_CAP_IRQ_ROUTING
  1401. :Architectures: x86 s390 arm64
  1402. :Type: vm ioctl
  1403. :Parameters: struct kvm_irq_routing (in)
  1404. :Returns: 0 on success, -1 on error
  1405. Sets the GSI routing table entries, overwriting any previously set entries.
  1406. On arm64, GSI routing has the following limitation:
  1407. - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD.
  1408. ::
  1409. struct kvm_irq_routing {
  1410. __u32 nr;
  1411. __u32 flags;
  1412. struct kvm_irq_routing_entry entries[0];
  1413. };
  1414. No flags are specified so far, the corresponding field must be set to zero.
  1415. ::
  1416. struct kvm_irq_routing_entry {
  1417. __u32 gsi;
  1418. __u32 type;
  1419. __u32 flags;
  1420. __u32 pad;
  1421. union {
  1422. struct kvm_irq_routing_irqchip irqchip;
  1423. struct kvm_irq_routing_msi msi;
  1424. struct kvm_irq_routing_s390_adapter adapter;
  1425. struct kvm_irq_routing_hv_sint hv_sint;
  1426. struct kvm_irq_routing_xen_evtchn xen_evtchn;
  1427. __u32 pad[8];
  1428. } u;
  1429. };
  1430. /* gsi routing entry types */
  1431. #define KVM_IRQ_ROUTING_IRQCHIP 1
  1432. #define KVM_IRQ_ROUTING_MSI 2
  1433. #define KVM_IRQ_ROUTING_S390_ADAPTER 3
  1434. #define KVM_IRQ_ROUTING_HV_SINT 4
  1435. #define KVM_IRQ_ROUTING_XEN_EVTCHN 5
  1436. flags:
  1437. - KVM_MSI_VALID_DEVID: used along with KVM_IRQ_ROUTING_MSI routing entry
  1438. type, specifies that the devid field contains a valid value. The per-VM
  1439. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  1440. the device ID. If this capability is not available, userspace should
  1441. never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  1442. - zero otherwise
  1443. ::
  1444. struct kvm_irq_routing_irqchip {
  1445. __u32 irqchip;
  1446. __u32 pin;
  1447. };
  1448. struct kvm_irq_routing_msi {
  1449. __u32 address_lo;
  1450. __u32 address_hi;
  1451. __u32 data;
  1452. union {
  1453. __u32 pad;
  1454. __u32 devid;
  1455. };
  1456. };
  1457. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  1458. for the device that wrote the MSI message. For PCI, this is usually a
  1459. BDF identifier in the lower 16 bits.
  1460. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  1461. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  1462. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  1463. address_hi must be zero.
  1464. ::
  1465. struct kvm_irq_routing_s390_adapter {
  1466. __u64 ind_addr;
  1467. __u64 summary_addr;
  1468. __u64 ind_offset;
  1469. __u32 summary_offset;
  1470. __u32 adapter_id;
  1471. };
  1472. struct kvm_irq_routing_hv_sint {
  1473. __u32 vcpu;
  1474. __u32 sint;
  1475. };
  1476. struct kvm_irq_routing_xen_evtchn {
  1477. __u32 port;
  1478. __u32 vcpu;
  1479. __u32 priority;
  1480. };
  1481. When KVM_CAP_XEN_HVM includes the KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL bit
  1482. in its indication of supported features, routing to Xen event channels
  1483. is supported. Although the priority field is present, only the value
  1484. KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL is supported, which means delivery by
  1485. 2 level event channels. FIFO event channel support may be added in
  1486. the future.
  1487. 4.55 KVM_SET_TSC_KHZ
  1488. --------------------
  1489. :Capability: KVM_CAP_TSC_CONTROL / KVM_CAP_VM_TSC_CONTROL
  1490. :Architectures: x86
  1491. :Type: vcpu ioctl / vm ioctl
  1492. :Parameters: virtual tsc_khz
  1493. :Returns: 0 on success, -1 on error
  1494. Specifies the tsc frequency for the virtual machine. The unit of the
  1495. frequency is KHz.
  1496. If the KVM_CAP_VM_TSC_CONTROL capability is advertised, this can also
  1497. be used as a vm ioctl to set the initial tsc frequency of subsequently
  1498. created vCPUs.
  1499. 4.56 KVM_GET_TSC_KHZ
  1500. --------------------
  1501. :Capability: KVM_CAP_GET_TSC_KHZ / KVM_CAP_VM_TSC_CONTROL
  1502. :Architectures: x86
  1503. :Type: vcpu ioctl / vm ioctl
  1504. :Parameters: none
  1505. :Returns: virtual tsc-khz on success, negative value on error
  1506. Returns the tsc frequency of the guest. The unit of the return value is
  1507. KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
  1508. error.
  1509. 4.57 KVM_GET_LAPIC
  1510. ------------------
  1511. :Capability: KVM_CAP_IRQCHIP
  1512. :Architectures: x86
  1513. :Type: vcpu ioctl
  1514. :Parameters: struct kvm_lapic_state (out)
  1515. :Returns: 0 on success, -1 on error
  1516. ::
  1517. #define KVM_APIC_REG_SIZE 0x400
  1518. struct kvm_lapic_state {
  1519. char regs[KVM_APIC_REG_SIZE];
  1520. };
  1521. Reads the Local APIC registers and copies them into the input argument. The
  1522. data format and layout are the same as documented in the architecture manual.
  1523. If KVM_X2APIC_API_USE_32BIT_IDS feature of KVM_CAP_X2APIC_API is
  1524. enabled, then the format of APIC_ID register depends on the APIC mode
  1525. (reported by MSR_IA32_APICBASE) of its VCPU. x2APIC stores APIC ID in
  1526. the APIC_ID register (bytes 32-35). xAPIC only allows an 8-bit APIC ID
  1527. which is stored in bits 31-24 of the APIC register, or equivalently in
  1528. byte 35 of struct kvm_lapic_state's regs field. KVM_GET_LAPIC must then
  1529. be called after MSR_IA32_APICBASE has been set with KVM_SET_MSR.
  1530. If KVM_X2APIC_API_USE_32BIT_IDS feature is disabled, struct kvm_lapic_state
  1531. always uses xAPIC format.
  1532. 4.58 KVM_SET_LAPIC
  1533. ------------------
  1534. :Capability: KVM_CAP_IRQCHIP
  1535. :Architectures: x86
  1536. :Type: vcpu ioctl
  1537. :Parameters: struct kvm_lapic_state (in)
  1538. :Returns: 0 on success, -1 on error
  1539. ::
  1540. #define KVM_APIC_REG_SIZE 0x400
  1541. struct kvm_lapic_state {
  1542. char regs[KVM_APIC_REG_SIZE];
  1543. };
  1544. Copies the input argument into the Local APIC registers. The data format
  1545. and layout are the same as documented in the architecture manual.
  1546. The format of the APIC ID register (bytes 32-35 of struct kvm_lapic_state's
  1547. regs field) depends on the state of the KVM_CAP_X2APIC_API capability.
  1548. See the note in KVM_GET_LAPIC.
  1549. 4.59 KVM_IOEVENTFD
  1550. ------------------
  1551. :Capability: KVM_CAP_IOEVENTFD
  1552. :Architectures: all
  1553. :Type: vm ioctl
  1554. :Parameters: struct kvm_ioeventfd (in)
  1555. :Returns: 0 on success, !0 on error
  1556. This ioctl attaches or detaches an ioeventfd to a legal pio/mmio address
  1557. within the guest. A guest write in the registered address will signal the
  1558. provided event instead of triggering an exit.
  1559. ::
  1560. struct kvm_ioeventfd {
  1561. __u64 datamatch;
  1562. __u64 addr; /* legal pio/mmio address */
  1563. __u32 len; /* 0, 1, 2, 4, or 8 bytes */
  1564. __s32 fd;
  1565. __u32 flags;
  1566. __u8 pad[36];
  1567. };
  1568. For the special case of virtio-ccw devices on s390, the ioevent is matched
  1569. to a subchannel/virtqueue tuple instead.
  1570. The following flags are defined::
  1571. #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
  1572. #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
  1573. #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
  1574. #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
  1575. (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
  1576. If datamatch flag is set, the event will be signaled only if the written value
  1577. to the registered address is equal to datamatch in struct kvm_ioeventfd.
  1578. For virtio-ccw devices, addr contains the subchannel id and datamatch the
  1579. virtqueue index.
  1580. With KVM_CAP_IOEVENTFD_ANY_LENGTH, a zero length ioeventfd is allowed, and
  1581. the kernel will ignore the length of guest write and may get a faster vmexit.
  1582. The speedup may only apply to specific architectures, but the ioeventfd will
  1583. work anyway.
  1584. 4.60 KVM_DIRTY_TLB
  1585. ------------------
  1586. :Capability: KVM_CAP_SW_TLB
  1587. :Architectures: ppc
  1588. :Type: vcpu ioctl
  1589. :Parameters: struct kvm_dirty_tlb (in)
  1590. :Returns: 0 on success, -1 on error
  1591. ::
  1592. struct kvm_dirty_tlb {
  1593. __u64 bitmap;
  1594. __u32 num_dirty;
  1595. };
  1596. This must be called whenever userspace has changed an entry in the shared
  1597. TLB, prior to calling KVM_RUN on the associated vcpu.
  1598. The "bitmap" field is the userspace address of an array. This array
  1599. consists of a number of bits, equal to the total number of TLB entries as
  1600. determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
  1601. nearest multiple of 64.
  1602. Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
  1603. array.
  1604. The array is little-endian: the bit 0 is the least significant bit of the
  1605. first byte, bit 8 is the least significant bit of the second byte, etc.
  1606. This avoids any complications with differing word sizes.
  1607. The "num_dirty" field is a performance hint for KVM to determine whether it
  1608. should skip processing the bitmap and just invalidate everything. It must
  1609. be set to the number of set bits in the bitmap.
  1610. 4.62 KVM_CREATE_SPAPR_TCE
  1611. -------------------------
  1612. :Capability: KVM_CAP_SPAPR_TCE
  1613. :Architectures: powerpc
  1614. :Type: vm ioctl
  1615. :Parameters: struct kvm_create_spapr_tce (in)
  1616. :Returns: file descriptor for manipulating the created TCE table
  1617. This creates a virtual TCE (translation control entry) table, which
  1618. is an IOMMU for PAPR-style virtual I/O. It is used to translate
  1619. logical addresses used in virtual I/O into guest physical addresses,
  1620. and provides a scatter/gather capability for PAPR virtual I/O.
  1621. ::
  1622. /* for KVM_CAP_SPAPR_TCE */
  1623. struct kvm_create_spapr_tce {
  1624. __u64 liobn;
  1625. __u32 window_size;
  1626. };
  1627. The liobn field gives the logical IO bus number for which to create a
  1628. TCE table. The window_size field specifies the size of the DMA window
  1629. which this TCE table will translate - the table will contain one 64
  1630. bit TCE entry for every 4kiB of the DMA window.
  1631. When the guest issues an H_PUT_TCE hcall on a liobn for which a TCE
  1632. table has been created using this ioctl(), the kernel will handle it
  1633. in real mode, updating the TCE table. H_PUT_TCE calls for other
  1634. liobns will cause a vm exit and must be handled by userspace.
  1635. The return value is a file descriptor which can be passed to mmap(2)
  1636. to map the created TCE table into userspace. This lets userspace read
  1637. the entries written by kernel-handled H_PUT_TCE calls, and also lets
  1638. userspace update the TCE table directly which is useful in some
  1639. circumstances.
  1640. 4.63 KVM_ALLOCATE_RMA
  1641. ---------------------
  1642. :Capability: KVM_CAP_PPC_RMA
  1643. :Architectures: powerpc
  1644. :Type: vm ioctl
  1645. :Parameters: struct kvm_allocate_rma (out)
  1646. :Returns: file descriptor for mapping the allocated RMA
  1647. This allocates a Real Mode Area (RMA) from the pool allocated at boot
  1648. time by the kernel. An RMA is a physically-contiguous, aligned region
  1649. of memory used on older POWER processors to provide the memory which
  1650. will be accessed by real-mode (MMU off) accesses in a KVM guest.
  1651. POWER processors support a set of sizes for the RMA that usually
  1652. includes 64MB, 128MB, 256MB and some larger powers of two.
  1653. ::
  1654. /* for KVM_ALLOCATE_RMA */
  1655. struct kvm_allocate_rma {
  1656. __u64 rma_size;
  1657. };
  1658. The return value is a file descriptor which can be passed to mmap(2)
  1659. to map the allocated RMA into userspace. The mapped area can then be
  1660. passed to the KVM_SET_USER_MEMORY_REGION ioctl to establish it as the
  1661. RMA for a virtual machine. The size of the RMA in bytes (which is
  1662. fixed at host kernel boot time) is returned in the rma_size field of
  1663. the argument structure.
  1664. The KVM_CAP_PPC_RMA capability is 1 or 2 if the KVM_ALLOCATE_RMA ioctl
  1665. is supported; 2 if the processor requires all virtual machines to have
  1666. an RMA, or 1 if the processor can use an RMA but doesn't require it,
  1667. because it supports the Virtual RMA (VRMA) facility.
  1668. 4.64 KVM_NMI
  1669. ------------
  1670. :Capability: KVM_CAP_USER_NMI
  1671. :Architectures: x86
  1672. :Type: vcpu ioctl
  1673. :Parameters: none
  1674. :Returns: 0 on success, -1 on error
  1675. Queues an NMI on the thread's vcpu. Note this is well defined only
  1676. when KVM_CREATE_IRQCHIP has not been called, since this is an interface
  1677. between the virtual cpu core and virtual local APIC. After KVM_CREATE_IRQCHIP
  1678. has been called, this interface is completely emulated within the kernel.
  1679. To use this to emulate the LINT1 input with KVM_CREATE_IRQCHIP, use the
  1680. following algorithm:
  1681. - pause the vcpu
  1682. - read the local APIC's state (KVM_GET_LAPIC)
  1683. - check whether changing LINT1 will queue an NMI (see the LVT entry for LINT1)
  1684. - if so, issue KVM_NMI
  1685. - resume the vcpu
  1686. Some guests configure the LINT1 NMI input to cause a panic, aiding in
  1687. debugging.
  1688. 4.65 KVM_S390_UCAS_MAP
  1689. ----------------------
  1690. :Capability: KVM_CAP_S390_UCONTROL
  1691. :Architectures: s390
  1692. :Type: vcpu ioctl
  1693. :Parameters: struct kvm_s390_ucas_mapping (in)
  1694. :Returns: 0 in case of success
  1695. The parameter is defined like this::
  1696. struct kvm_s390_ucas_mapping {
  1697. __u64 user_addr;
  1698. __u64 vcpu_addr;
  1699. __u64 length;
  1700. };
  1701. This ioctl maps the memory at "user_addr" with the length "length" to
  1702. the vcpu's address space starting at "vcpu_addr". All parameters need to
  1703. be aligned by 1 megabyte.
  1704. 4.66 KVM_S390_UCAS_UNMAP
  1705. ------------------------
  1706. :Capability: KVM_CAP_S390_UCONTROL
  1707. :Architectures: s390
  1708. :Type: vcpu ioctl
  1709. :Parameters: struct kvm_s390_ucas_mapping (in)
  1710. :Returns: 0 in case of success
  1711. The parameter is defined like this::
  1712. struct kvm_s390_ucas_mapping {
  1713. __u64 user_addr;
  1714. __u64 vcpu_addr;
  1715. __u64 length;
  1716. };
  1717. This ioctl unmaps the memory in the vcpu's address space starting at
  1718. "vcpu_addr" with the length "length". The field "user_addr" is ignored.
  1719. All parameters need to be aligned by 1 megabyte.
  1720. 4.67 KVM_S390_VCPU_FAULT
  1721. ------------------------
  1722. :Capability: KVM_CAP_S390_UCONTROL
  1723. :Architectures: s390
  1724. :Type: vcpu ioctl
  1725. :Parameters: vcpu absolute address (in)
  1726. :Returns: 0 in case of success
  1727. This call creates a page table entry on the virtual cpu's address space
  1728. (for user controlled virtual machines) or the virtual machine's address
  1729. space (for regular virtual machines). This only works for minor faults,
  1730. thus it's recommended to access subject memory page via the user page
  1731. table upfront. This is useful to handle validity intercepts for user
  1732. controlled virtual machines to fault in the virtual cpu's lowcore pages
  1733. prior to calling the KVM_RUN ioctl.
  1734. 4.68 KVM_SET_ONE_REG
  1735. --------------------
  1736. :Capability: KVM_CAP_ONE_REG
  1737. :Architectures: all
  1738. :Type: vcpu ioctl
  1739. :Parameters: struct kvm_one_reg (in)
  1740. :Returns: 0 on success, negative value on failure
  1741. Errors:
  1742. ====== ============================================================
  1743. ENOENT no such register
  1744. EINVAL invalid register ID, or no such register or used with VMs in
  1745. protected virtualization mode on s390
  1746. EPERM (arm64) register access not allowed before vcpu finalization
  1747. EBUSY (riscv) changing register value not allowed after the vcpu
  1748. has run at least once
  1749. ====== ============================================================
  1750. (These error codes are indicative only: do not rely on a specific error
  1751. code being returned in a specific situation.)
  1752. ::
  1753. struct kvm_one_reg {
  1754. __u64 id;
  1755. __u64 addr;
  1756. };
  1757. Using this ioctl, a single vcpu register can be set to a specific value
  1758. defined by user space with the passed in struct kvm_one_reg, where id
  1759. refers to the register identifier as described below and addr is a pointer
  1760. to a variable with the respective size. There can be architecture agnostic
  1761. and architecture specific registers. Each have their own range of operation
  1762. and their own constants and width. To keep track of the implemented
  1763. registers, find a list below:
  1764. ======= =============================== ============
  1765. Arch Register Width (bits)
  1766. ======= =============================== ============
  1767. PPC KVM_REG_PPC_HIOR 64
  1768. PPC KVM_REG_PPC_IAC1 64
  1769. PPC KVM_REG_PPC_IAC2 64
  1770. PPC KVM_REG_PPC_IAC3 64
  1771. PPC KVM_REG_PPC_IAC4 64
  1772. PPC KVM_REG_PPC_DAC1 64
  1773. PPC KVM_REG_PPC_DAC2 64
  1774. PPC KVM_REG_PPC_DABR 64
  1775. PPC KVM_REG_PPC_DSCR 64
  1776. PPC KVM_REG_PPC_PURR 64
  1777. PPC KVM_REG_PPC_SPURR 64
  1778. PPC KVM_REG_PPC_DAR 64
  1779. PPC KVM_REG_PPC_DSISR 32
  1780. PPC KVM_REG_PPC_AMR 64
  1781. PPC KVM_REG_PPC_UAMOR 64
  1782. PPC KVM_REG_PPC_MMCR0 64
  1783. PPC KVM_REG_PPC_MMCR1 64
  1784. PPC KVM_REG_PPC_MMCRA 64
  1785. PPC KVM_REG_PPC_MMCR2 64
  1786. PPC KVM_REG_PPC_MMCRS 64
  1787. PPC KVM_REG_PPC_MMCR3 64
  1788. PPC KVM_REG_PPC_SIAR 64
  1789. PPC KVM_REG_PPC_SDAR 64
  1790. PPC KVM_REG_PPC_SIER 64
  1791. PPC KVM_REG_PPC_SIER2 64
  1792. PPC KVM_REG_PPC_SIER3 64
  1793. PPC KVM_REG_PPC_PMC1 32
  1794. PPC KVM_REG_PPC_PMC2 32
  1795. PPC KVM_REG_PPC_PMC3 32
  1796. PPC KVM_REG_PPC_PMC4 32
  1797. PPC KVM_REG_PPC_PMC5 32
  1798. PPC KVM_REG_PPC_PMC6 32
  1799. PPC KVM_REG_PPC_PMC7 32
  1800. PPC KVM_REG_PPC_PMC8 32
  1801. PPC KVM_REG_PPC_FPR0 64
  1802. ...
  1803. PPC KVM_REG_PPC_FPR31 64
  1804. PPC KVM_REG_PPC_VR0 128
  1805. ...
  1806. PPC KVM_REG_PPC_VR31 128
  1807. PPC KVM_REG_PPC_VSR0 128
  1808. ...
  1809. PPC KVM_REG_PPC_VSR31 128
  1810. PPC KVM_REG_PPC_FPSCR 64
  1811. PPC KVM_REG_PPC_VSCR 32
  1812. PPC KVM_REG_PPC_VPA_ADDR 64
  1813. PPC KVM_REG_PPC_VPA_SLB 128
  1814. PPC KVM_REG_PPC_VPA_DTL 128
  1815. PPC KVM_REG_PPC_EPCR 32
  1816. PPC KVM_REG_PPC_EPR 32
  1817. PPC KVM_REG_PPC_TCR 32
  1818. PPC KVM_REG_PPC_TSR 32
  1819. PPC KVM_REG_PPC_OR_TSR 32
  1820. PPC KVM_REG_PPC_CLEAR_TSR 32
  1821. PPC KVM_REG_PPC_MAS0 32
  1822. PPC KVM_REG_PPC_MAS1 32
  1823. PPC KVM_REG_PPC_MAS2 64
  1824. PPC KVM_REG_PPC_MAS7_3 64
  1825. PPC KVM_REG_PPC_MAS4 32
  1826. PPC KVM_REG_PPC_MAS6 32
  1827. PPC KVM_REG_PPC_MMUCFG 32
  1828. PPC KVM_REG_PPC_TLB0CFG 32
  1829. PPC KVM_REG_PPC_TLB1CFG 32
  1830. PPC KVM_REG_PPC_TLB2CFG 32
  1831. PPC KVM_REG_PPC_TLB3CFG 32
  1832. PPC KVM_REG_PPC_TLB0PS 32
  1833. PPC KVM_REG_PPC_TLB1PS 32
  1834. PPC KVM_REG_PPC_TLB2PS 32
  1835. PPC KVM_REG_PPC_TLB3PS 32
  1836. PPC KVM_REG_PPC_EPTCFG 32
  1837. PPC KVM_REG_PPC_ICP_STATE 64
  1838. PPC KVM_REG_PPC_VP_STATE 128
  1839. PPC KVM_REG_PPC_TB_OFFSET 64
  1840. PPC KVM_REG_PPC_SPMC1 32
  1841. PPC KVM_REG_PPC_SPMC2 32
  1842. PPC KVM_REG_PPC_IAMR 64
  1843. PPC KVM_REG_PPC_TFHAR 64
  1844. PPC KVM_REG_PPC_TFIAR 64
  1845. PPC KVM_REG_PPC_TEXASR 64
  1846. PPC KVM_REG_PPC_FSCR 64
  1847. PPC KVM_REG_PPC_PSPB 32
  1848. PPC KVM_REG_PPC_EBBHR 64
  1849. PPC KVM_REG_PPC_EBBRR 64
  1850. PPC KVM_REG_PPC_BESCR 64
  1851. PPC KVM_REG_PPC_TAR 64
  1852. PPC KVM_REG_PPC_DPDES 64
  1853. PPC KVM_REG_PPC_DAWR 64
  1854. PPC KVM_REG_PPC_DAWRX 64
  1855. PPC KVM_REG_PPC_CIABR 64
  1856. PPC KVM_REG_PPC_IC 64
  1857. PPC KVM_REG_PPC_VTB 64
  1858. PPC KVM_REG_PPC_CSIGR 64
  1859. PPC KVM_REG_PPC_TACR 64
  1860. PPC KVM_REG_PPC_TCSCR 64
  1861. PPC KVM_REG_PPC_PID 64
  1862. PPC KVM_REG_PPC_ACOP 64
  1863. PPC KVM_REG_PPC_VRSAVE 32
  1864. PPC KVM_REG_PPC_LPCR 32
  1865. PPC KVM_REG_PPC_LPCR_64 64
  1866. PPC KVM_REG_PPC_PPR 64
  1867. PPC KVM_REG_PPC_ARCH_COMPAT 32
  1868. PPC KVM_REG_PPC_DABRX 32
  1869. PPC KVM_REG_PPC_WORT 64
  1870. PPC KVM_REG_PPC_SPRG9 64
  1871. PPC KVM_REG_PPC_DBSR 32
  1872. PPC KVM_REG_PPC_TIDR 64
  1873. PPC KVM_REG_PPC_PSSCR 64
  1874. PPC KVM_REG_PPC_DEC_EXPIRY 64
  1875. PPC KVM_REG_PPC_PTCR 64
  1876. PPC KVM_REG_PPC_HASHKEYR 64
  1877. PPC KVM_REG_PPC_HASHPKEYR 64
  1878. PPC KVM_REG_PPC_DAWR1 64
  1879. PPC KVM_REG_PPC_DAWRX1 64
  1880. PPC KVM_REG_PPC_DEXCR 64
  1881. PPC KVM_REG_PPC_TM_GPR0 64
  1882. ...
  1883. PPC KVM_REG_PPC_TM_GPR31 64
  1884. PPC KVM_REG_PPC_TM_VSR0 128
  1885. ...
  1886. PPC KVM_REG_PPC_TM_VSR63 128
  1887. PPC KVM_REG_PPC_TM_CR 64
  1888. PPC KVM_REG_PPC_TM_LR 64
  1889. PPC KVM_REG_PPC_TM_CTR 64
  1890. PPC KVM_REG_PPC_TM_FPSCR 64
  1891. PPC KVM_REG_PPC_TM_AMR 64
  1892. PPC KVM_REG_PPC_TM_PPR 64
  1893. PPC KVM_REG_PPC_TM_VRSAVE 64
  1894. PPC KVM_REG_PPC_TM_VSCR 32
  1895. PPC KVM_REG_PPC_TM_DSCR 64
  1896. PPC KVM_REG_PPC_TM_TAR 64
  1897. PPC KVM_REG_PPC_TM_XER 64
  1898. MIPS KVM_REG_MIPS_R0 64
  1899. ...
  1900. MIPS KVM_REG_MIPS_R31 64
  1901. MIPS KVM_REG_MIPS_HI 64
  1902. MIPS KVM_REG_MIPS_LO 64
  1903. MIPS KVM_REG_MIPS_PC 64
  1904. MIPS KVM_REG_MIPS_CP0_INDEX 32
  1905. MIPS KVM_REG_MIPS_CP0_ENTRYLO0 64
  1906. MIPS KVM_REG_MIPS_CP0_ENTRYLO1 64
  1907. MIPS KVM_REG_MIPS_CP0_CONTEXT 64
  1908. MIPS KVM_REG_MIPS_CP0_CONTEXTCONFIG 32
  1909. MIPS KVM_REG_MIPS_CP0_USERLOCAL 64
  1910. MIPS KVM_REG_MIPS_CP0_XCONTEXTCONFIG 64
  1911. MIPS KVM_REG_MIPS_CP0_PAGEMASK 32
  1912. MIPS KVM_REG_MIPS_CP0_PAGEGRAIN 32
  1913. MIPS KVM_REG_MIPS_CP0_SEGCTL0 64
  1914. MIPS KVM_REG_MIPS_CP0_SEGCTL1 64
  1915. MIPS KVM_REG_MIPS_CP0_SEGCTL2 64
  1916. MIPS KVM_REG_MIPS_CP0_PWBASE 64
  1917. MIPS KVM_REG_MIPS_CP0_PWFIELD 64
  1918. MIPS KVM_REG_MIPS_CP0_PWSIZE 64
  1919. MIPS KVM_REG_MIPS_CP0_WIRED 32
  1920. MIPS KVM_REG_MIPS_CP0_PWCTL 32
  1921. MIPS KVM_REG_MIPS_CP0_HWRENA 32
  1922. MIPS KVM_REG_MIPS_CP0_BADVADDR 64
  1923. MIPS KVM_REG_MIPS_CP0_BADINSTR 32
  1924. MIPS KVM_REG_MIPS_CP0_BADINSTRP 32
  1925. MIPS KVM_REG_MIPS_CP0_COUNT 32
  1926. MIPS KVM_REG_MIPS_CP0_ENTRYHI 64
  1927. MIPS KVM_REG_MIPS_CP0_COMPARE 32
  1928. MIPS KVM_REG_MIPS_CP0_STATUS 32
  1929. MIPS KVM_REG_MIPS_CP0_INTCTL 32
  1930. MIPS KVM_REG_MIPS_CP0_CAUSE 32
  1931. MIPS KVM_REG_MIPS_CP0_EPC 64
  1932. MIPS KVM_REG_MIPS_CP0_PRID 32
  1933. MIPS KVM_REG_MIPS_CP0_EBASE 64
  1934. MIPS KVM_REG_MIPS_CP0_CONFIG 32
  1935. MIPS KVM_REG_MIPS_CP0_CONFIG1 32
  1936. MIPS KVM_REG_MIPS_CP0_CONFIG2 32
  1937. MIPS KVM_REG_MIPS_CP0_CONFIG3 32
  1938. MIPS KVM_REG_MIPS_CP0_CONFIG4 32
  1939. MIPS KVM_REG_MIPS_CP0_CONFIG5 32
  1940. MIPS KVM_REG_MIPS_CP0_CONFIG7 32
  1941. MIPS KVM_REG_MIPS_CP0_XCONTEXT 64
  1942. MIPS KVM_REG_MIPS_CP0_ERROREPC 64
  1943. MIPS KVM_REG_MIPS_CP0_KSCRATCH1 64
  1944. MIPS KVM_REG_MIPS_CP0_KSCRATCH2 64
  1945. MIPS KVM_REG_MIPS_CP0_KSCRATCH3 64
  1946. MIPS KVM_REG_MIPS_CP0_KSCRATCH4 64
  1947. MIPS KVM_REG_MIPS_CP0_KSCRATCH5 64
  1948. MIPS KVM_REG_MIPS_CP0_KSCRATCH6 64
  1949. MIPS KVM_REG_MIPS_CP0_MAAR(0..63) 64
  1950. MIPS KVM_REG_MIPS_COUNT_CTL 64
  1951. MIPS KVM_REG_MIPS_COUNT_RESUME 64
  1952. MIPS KVM_REG_MIPS_COUNT_HZ 64
  1953. MIPS KVM_REG_MIPS_FPR_32(0..31) 32
  1954. MIPS KVM_REG_MIPS_FPR_64(0..31) 64
  1955. MIPS KVM_REG_MIPS_VEC_128(0..31) 128
  1956. MIPS KVM_REG_MIPS_FCR_IR 32
  1957. MIPS KVM_REG_MIPS_FCR_CSR 32
  1958. MIPS KVM_REG_MIPS_MSA_IR 32
  1959. MIPS KVM_REG_MIPS_MSA_CSR 32
  1960. ======= =============================== ============
  1961. ARM registers are mapped using the lower 32 bits. The upper 16 of that
  1962. is the register group type, or coprocessor number:
  1963. ARM core registers have the following id bit patterns::
  1964. 0x4020 0000 0010 <index into the kvm_regs struct:16>
  1965. ARM 32-bit CP15 registers have the following id bit patterns::
  1966. 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3>
  1967. ARM 64-bit CP15 registers have the following id bit patterns::
  1968. 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3>
  1969. ARM CCSIDR registers are demultiplexed by CSSELR value::
  1970. 0x4020 0000 0011 00 <csselr:8>
  1971. ARM 32-bit VFP control registers have the following id bit patterns::
  1972. 0x4020 0000 0012 1 <regno:12>
  1973. ARM 64-bit FP registers have the following id bit patterns::
  1974. 0x4030 0000 0012 0 <regno:12>
  1975. ARM firmware pseudo-registers have the following bit pattern::
  1976. 0x4030 0000 0014 <regno:16>
  1977. arm64 registers are mapped using the lower 32 bits. The upper 16 of
  1978. that is the register group type, or coprocessor number:
  1979. arm64 core/FP-SIMD registers have the following id bit patterns. Note
  1980. that the size of the access is variable, as the kvm_regs structure
  1981. contains elements ranging from 32 to 128 bits. The index is a 32bit
  1982. value in the kvm_regs structure seen as a 32bit array::
  1983. 0x60x0 0000 0010 <index into the kvm_regs struct:16>
  1984. Specifically:
  1985. ======================= ========= ===== =======================================
  1986. Encoding Register Bits kvm_regs member
  1987. ======================= ========= ===== =======================================
  1988. 0x6030 0000 0010 0000 X0 64 regs.regs[0]
  1989. 0x6030 0000 0010 0002 X1 64 regs.regs[1]
  1990. ...
  1991. 0x6030 0000 0010 003c X30 64 regs.regs[30]
  1992. 0x6030 0000 0010 003e SP 64 regs.sp
  1993. 0x6030 0000 0010 0040 PC 64 regs.pc
  1994. 0x6030 0000 0010 0042 PSTATE 64 regs.pstate
  1995. 0x6030 0000 0010 0044 SP_EL1 64 sp_el1
  1996. 0x6030 0000 0010 0046 ELR_EL1 64 elr_el1
  1997. 0x6030 0000 0010 0048 SPSR_EL1 64 spsr[KVM_SPSR_EL1] (alias SPSR_SVC)
  1998. 0x6030 0000 0010 004a SPSR_ABT 64 spsr[KVM_SPSR_ABT]
  1999. 0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND]
  2000. 0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ]
  2001. 0x6030 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ]
  2002. 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] [1]_
  2003. 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] [1]_
  2004. ...
  2005. 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31] [1]_
  2006. 0x6020 0000 0010 00d4 FPSR 32 fp_regs.fpsr
  2007. 0x6020 0000 0010 00d5 FPCR 32 fp_regs.fpcr
  2008. ======================= ========= ===== =======================================
  2009. .. [1] These encodings are not accepted for SVE-enabled vcpus. See
  2010. KVM_ARM_VCPU_INIT.
  2011. The equivalent register content can be accessed via bits [127:0] of
  2012. the corresponding SVE Zn registers instead for vcpus that have SVE
  2013. enabled (see below).
  2014. arm64 CCSIDR registers are demultiplexed by CSSELR value::
  2015. 0x6020 0000 0011 00 <csselr:8>
  2016. arm64 system registers have the following id bit patterns::
  2017. 0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
  2018. .. warning::
  2019. Two system register IDs do not follow the specified pattern. These
  2020. are KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT, which map to
  2021. system registers CNTV_CVAL_EL0 and CNTVCT_EL0 respectively. These
  2022. two had their values accidentally swapped, which means TIMER_CVAL is
  2023. derived from the register encoding for CNTVCT_EL0 and TIMER_CNT is
  2024. derived from the register encoding for CNTV_CVAL_EL0. As this is
  2025. API, it must remain this way.
  2026. arm64 firmware pseudo-registers have the following bit pattern::
  2027. 0x6030 0000 0014 <regno:16>
  2028. arm64 SVE registers have the following bit patterns::
  2029. 0x6080 0000 0015 00 <n:5> <slice:5> Zn bits[2048*slice + 2047 : 2048*slice]
  2030. 0x6050 0000 0015 04 <n:4> <slice:5> Pn bits[256*slice + 255 : 256*slice]
  2031. 0x6050 0000 0015 060 <slice:5> FFR bits[256*slice + 255 : 256*slice]
  2032. 0x6060 0000 0015 ffff KVM_REG_ARM64_SVE_VLS pseudo-register
  2033. Access to register IDs where 2048 * slice >= 128 * max_vq will fail with
  2034. ENOENT. max_vq is the vcpu's maximum supported vector length in 128-bit
  2035. quadwords: see [2]_ below.
  2036. These registers are only accessible on vcpus for which SVE is enabled.
  2037. See KVM_ARM_VCPU_INIT for details.
  2038. In addition, except for KVM_REG_ARM64_SVE_VLS, these registers are not
  2039. accessible until the vcpu's SVE configuration has been finalized
  2040. using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). See KVM_ARM_VCPU_INIT
  2041. and KVM_ARM_VCPU_FINALIZE for more information about this procedure.
  2042. KVM_REG_ARM64_SVE_VLS is a pseudo-register that allows the set of vector
  2043. lengths supported by the vcpu to be discovered and configured by
  2044. userspace. When transferred to or from user memory via KVM_GET_ONE_REG
  2045. or KVM_SET_ONE_REG, the value of this register is of type
  2046. __u64[KVM_ARM64_SVE_VLS_WORDS], and encodes the set of vector lengths as
  2047. follows::
  2048. __u64 vector_lengths[KVM_ARM64_SVE_VLS_WORDS];
  2049. if (vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX &&
  2050. ((vector_lengths[(vq - KVM_ARM64_SVE_VQ_MIN) / 64] >>
  2051. ((vq - KVM_ARM64_SVE_VQ_MIN) % 64)) & 1))
  2052. /* Vector length vq * 16 bytes supported */
  2053. else
  2054. /* Vector length vq * 16 bytes not supported */
  2055. .. [2] The maximum value vq for which the above condition is true is
  2056. max_vq. This is the maximum vector length available to the guest on
  2057. this vcpu, and determines which register slices are visible through
  2058. this ioctl interface.
  2059. (See Documentation/arch/arm64/sve.rst for an explanation of the "vq"
  2060. nomenclature.)
  2061. KVM_REG_ARM64_SVE_VLS is only accessible after KVM_ARM_VCPU_INIT.
  2062. KVM_ARM_VCPU_INIT initialises it to the best set of vector lengths that
  2063. the host supports.
  2064. Userspace may subsequently modify it if desired until the vcpu's SVE
  2065. configuration is finalized using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE).
  2066. Apart from simply removing all vector lengths from the host set that
  2067. exceed some value, support for arbitrarily chosen sets of vector lengths
  2068. is hardware-dependent and may not be available. Attempting to configure
  2069. an invalid set of vector lengths via KVM_SET_ONE_REG will fail with
  2070. EINVAL.
  2071. After the vcpu's SVE configuration is finalized, further attempts to
  2072. write this register will fail with EPERM.
  2073. arm64 bitmap feature firmware pseudo-registers have the following bit pattern::
  2074. 0x6030 0000 0016 <regno:16>
  2075. The bitmap feature firmware registers exposes the hypercall services that
  2076. are available for userspace to configure. The set bits corresponds to the
  2077. services that are available for the guests to access. By default, KVM
  2078. sets all the supported bits during VM initialization. The userspace can
  2079. discover the available services via KVM_GET_ONE_REG, and write back the
  2080. bitmap corresponding to the features that it wishes guests to see via
  2081. KVM_SET_ONE_REG.
  2082. Note: These registers are immutable once any of the vCPUs of the VM has
  2083. run at least once. A KVM_SET_ONE_REG in such a scenario will return
  2084. a -EBUSY to userspace.
  2085. (See Documentation/virt/kvm/arm/hypercalls.rst for more details.)
  2086. MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
  2087. the register group type:
  2088. MIPS core registers (see above) have the following id bit patterns::
  2089. 0x7030 0000 0000 <reg:16>
  2090. MIPS CP0 registers (see KVM_REG_MIPS_CP0_* above) have the following id bit
  2091. patterns depending on whether they're 32-bit or 64-bit registers::
  2092. 0x7020 0000 0001 00 <reg:5> <sel:3> (32-bit)
  2093. 0x7030 0000 0001 00 <reg:5> <sel:3> (64-bit)
  2094. Note: KVM_REG_MIPS_CP0_ENTRYLO0 and KVM_REG_MIPS_CP0_ENTRYLO1 are the MIPS64
  2095. versions of the EntryLo registers regardless of the word size of the host
  2096. hardware, host kernel, guest, and whether XPA is present in the guest, i.e.
  2097. with the RI and XI bits (if they exist) in bits 63 and 62 respectively, and
  2098. the PFNX field starting at bit 30.
  2099. MIPS MAARs (see KVM_REG_MIPS_CP0_MAAR(*) above) have the following id bit
  2100. patterns::
  2101. 0x7030 0000 0001 01 <reg:8>
  2102. MIPS KVM control registers (see above) have the following id bit patterns::
  2103. 0x7030 0000 0002 <reg:16>
  2104. MIPS FPU registers (see KVM_REG_MIPS_FPR_{32,64}() above) have the following
  2105. id bit patterns depending on the size of the register being accessed. They are
  2106. always accessed according to the current guest FPU mode (Status.FR and
  2107. Config5.FRE), i.e. as the guest would see them, and they become unpredictable
  2108. if the guest FPU mode is changed. MIPS SIMD Architecture (MSA) vector
  2109. registers (see KVM_REG_MIPS_VEC_128() above) have similar patterns as they
  2110. overlap the FPU registers::
  2111. 0x7020 0000 0003 00 <0:3> <reg:5> (32-bit FPU registers)
  2112. 0x7030 0000 0003 00 <0:3> <reg:5> (64-bit FPU registers)
  2113. 0x7040 0000 0003 00 <0:3> <reg:5> (128-bit MSA vector registers)
  2114. MIPS FPU control registers (see KVM_REG_MIPS_FCR_{IR,CSR} above) have the
  2115. following id bit patterns::
  2116. 0x7020 0000 0003 01 <0:3> <reg:5>
  2117. MIPS MSA control registers (see KVM_REG_MIPS_MSA_{IR,CSR} above) have the
  2118. following id bit patterns::
  2119. 0x7020 0000 0003 02 <0:3> <reg:5>
  2120. RISC-V registers are mapped using the lower 32 bits. The upper 8 bits of
  2121. that is the register group type.
  2122. RISC-V config registers are meant for configuring a Guest VCPU and it has
  2123. the following id bit patterns::
  2124. 0x8020 0000 01 <index into the kvm_riscv_config struct:24> (32bit Host)
  2125. 0x8030 0000 01 <index into the kvm_riscv_config struct:24> (64bit Host)
  2126. Following are the RISC-V config registers:
  2127. ======================= ========= =============================================
  2128. Encoding Register Description
  2129. ======================= ========= =============================================
  2130. 0x80x0 0000 0100 0000 isa ISA feature bitmap of Guest VCPU
  2131. ======================= ========= =============================================
  2132. The isa config register can be read anytime but can only be written before
  2133. a Guest VCPU runs. It will have ISA feature bits matching underlying host
  2134. set by default.
  2135. RISC-V core registers represent the general execution state of a Guest VCPU
  2136. and it has the following id bit patterns::
  2137. 0x8020 0000 02 <index into the kvm_riscv_core struct:24> (32bit Host)
  2138. 0x8030 0000 02 <index into the kvm_riscv_core struct:24> (64bit Host)
  2139. Following are the RISC-V core registers:
  2140. ======================= ========= =============================================
  2141. Encoding Register Description
  2142. ======================= ========= =============================================
  2143. 0x80x0 0000 0200 0000 regs.pc Program counter
  2144. 0x80x0 0000 0200 0001 regs.ra Return address
  2145. 0x80x0 0000 0200 0002 regs.sp Stack pointer
  2146. 0x80x0 0000 0200 0003 regs.gp Global pointer
  2147. 0x80x0 0000 0200 0004 regs.tp Task pointer
  2148. 0x80x0 0000 0200 0005 regs.t0 Caller saved register 0
  2149. 0x80x0 0000 0200 0006 regs.t1 Caller saved register 1
  2150. 0x80x0 0000 0200 0007 regs.t2 Caller saved register 2
  2151. 0x80x0 0000 0200 0008 regs.s0 Callee saved register 0
  2152. 0x80x0 0000 0200 0009 regs.s1 Callee saved register 1
  2153. 0x80x0 0000 0200 000a regs.a0 Function argument (or return value) 0
  2154. 0x80x0 0000 0200 000b regs.a1 Function argument (or return value) 1
  2155. 0x80x0 0000 0200 000c regs.a2 Function argument 2
  2156. 0x80x0 0000 0200 000d regs.a3 Function argument 3
  2157. 0x80x0 0000 0200 000e regs.a4 Function argument 4
  2158. 0x80x0 0000 0200 000f regs.a5 Function argument 5
  2159. 0x80x0 0000 0200 0010 regs.a6 Function argument 6
  2160. 0x80x0 0000 0200 0011 regs.a7 Function argument 7
  2161. 0x80x0 0000 0200 0012 regs.s2 Callee saved register 2
  2162. 0x80x0 0000 0200 0013 regs.s3 Callee saved register 3
  2163. 0x80x0 0000 0200 0014 regs.s4 Callee saved register 4
  2164. 0x80x0 0000 0200 0015 regs.s5 Callee saved register 5
  2165. 0x80x0 0000 0200 0016 regs.s6 Callee saved register 6
  2166. 0x80x0 0000 0200 0017 regs.s7 Callee saved register 7
  2167. 0x80x0 0000 0200 0018 regs.s8 Callee saved register 8
  2168. 0x80x0 0000 0200 0019 regs.s9 Callee saved register 9
  2169. 0x80x0 0000 0200 001a regs.s10 Callee saved register 10
  2170. 0x80x0 0000 0200 001b regs.s11 Callee saved register 11
  2171. 0x80x0 0000 0200 001c regs.t3 Caller saved register 3
  2172. 0x80x0 0000 0200 001d regs.t4 Caller saved register 4
  2173. 0x80x0 0000 0200 001e regs.t5 Caller saved register 5
  2174. 0x80x0 0000 0200 001f regs.t6 Caller saved register 6
  2175. 0x80x0 0000 0200 0020 mode Privilege mode (1 = S-mode or 0 = U-mode)
  2176. ======================= ========= =============================================
  2177. RISC-V csr registers represent the supervisor mode control/status registers
  2178. of a Guest VCPU and it has the following id bit patterns::
  2179. 0x8020 0000 03 <index into the kvm_riscv_csr struct:24> (32bit Host)
  2180. 0x8030 0000 03 <index into the kvm_riscv_csr struct:24> (64bit Host)
  2181. Following are the RISC-V csr registers:
  2182. ======================= ========= =============================================
  2183. Encoding Register Description
  2184. ======================= ========= =============================================
  2185. 0x80x0 0000 0300 0000 sstatus Supervisor status
  2186. 0x80x0 0000 0300 0001 sie Supervisor interrupt enable
  2187. 0x80x0 0000 0300 0002 stvec Supervisor trap vector base
  2188. 0x80x0 0000 0300 0003 sscratch Supervisor scratch register
  2189. 0x80x0 0000 0300 0004 sepc Supervisor exception program counter
  2190. 0x80x0 0000 0300 0005 scause Supervisor trap cause
  2191. 0x80x0 0000 0300 0006 stval Supervisor bad address or instruction
  2192. 0x80x0 0000 0300 0007 sip Supervisor interrupt pending
  2193. 0x80x0 0000 0300 0008 satp Supervisor address translation and protection
  2194. ======================= ========= =============================================
  2195. RISC-V timer registers represent the timer state of a Guest VCPU and it has
  2196. the following id bit patterns::
  2197. 0x8030 0000 04 <index into the kvm_riscv_timer struct:24>
  2198. Following are the RISC-V timer registers:
  2199. ======================= ========= =============================================
  2200. Encoding Register Description
  2201. ======================= ========= =============================================
  2202. 0x8030 0000 0400 0000 frequency Time base frequency (read-only)
  2203. 0x8030 0000 0400 0001 time Time value visible to Guest
  2204. 0x8030 0000 0400 0002 compare Time compare programmed by Guest
  2205. 0x8030 0000 0400 0003 state Time compare state (1 = ON or 0 = OFF)
  2206. ======================= ========= =============================================
  2207. RISC-V F-extension registers represent the single precision floating point
  2208. state of a Guest VCPU and it has the following id bit patterns::
  2209. 0x8020 0000 05 <index into the __riscv_f_ext_state struct:24>
  2210. Following are the RISC-V F-extension registers:
  2211. ======================= ========= =============================================
  2212. Encoding Register Description
  2213. ======================= ========= =============================================
  2214. 0x8020 0000 0500 0000 f[0] Floating point register 0
  2215. ...
  2216. 0x8020 0000 0500 001f f[31] Floating point register 31
  2217. 0x8020 0000 0500 0020 fcsr Floating point control and status register
  2218. ======================= ========= =============================================
  2219. RISC-V D-extension registers represent the double precision floating point
  2220. state of a Guest VCPU and it has the following id bit patterns::
  2221. 0x8020 0000 06 <index into the __riscv_d_ext_state struct:24> (fcsr)
  2222. 0x8030 0000 06 <index into the __riscv_d_ext_state struct:24> (non-fcsr)
  2223. Following are the RISC-V D-extension registers:
  2224. ======================= ========= =============================================
  2225. Encoding Register Description
  2226. ======================= ========= =============================================
  2227. 0x8030 0000 0600 0000 f[0] Floating point register 0
  2228. ...
  2229. 0x8030 0000 0600 001f f[31] Floating point register 31
  2230. 0x8020 0000 0600 0020 fcsr Floating point control and status register
  2231. ======================= ========= =============================================
  2232. LoongArch registers are mapped using the lower 32 bits. The upper 16 bits of
  2233. that is the register group type.
  2234. LoongArch csr registers are used to control guest cpu or get status of guest
  2235. cpu, and they have the following id bit patterns::
  2236. 0x9030 0000 0001 00 <reg:5> <sel:3> (64-bit)
  2237. LoongArch KVM control registers are used to implement some new defined functions
  2238. such as set vcpu counter or reset vcpu, and they have the following id bit patterns::
  2239. 0x9030 0000 0002 <reg:16>
  2240. 4.69 KVM_GET_ONE_REG
  2241. --------------------
  2242. :Capability: KVM_CAP_ONE_REG
  2243. :Architectures: all
  2244. :Type: vcpu ioctl
  2245. :Parameters: struct kvm_one_reg (in and out)
  2246. :Returns: 0 on success, negative value on failure
  2247. Errors include:
  2248. ======== ============================================================
  2249. ENOENT no such register
  2250. EINVAL invalid register ID, or no such register or used with VMs in
  2251. protected virtualization mode on s390
  2252. EPERM (arm64) register access not allowed before vcpu finalization
  2253. ======== ============================================================
  2254. (These error codes are indicative only: do not rely on a specific error
  2255. code being returned in a specific situation.)
  2256. This ioctl allows to receive the value of a single register implemented
  2257. in a vcpu. The register to read is indicated by the "id" field of the
  2258. kvm_one_reg struct passed in. On success, the register value can be found
  2259. at the memory location pointed to by "addr".
  2260. The list of registers accessible using this interface is identical to the
  2261. list in 4.68.
  2262. 4.70 KVM_KVMCLOCK_CTRL
  2263. ----------------------
  2264. :Capability: KVM_CAP_KVMCLOCK_CTRL
  2265. :Architectures: Any that implement pvclocks (currently x86 only)
  2266. :Type: vcpu ioctl
  2267. :Parameters: None
  2268. :Returns: 0 on success, -1 on error
  2269. This ioctl sets a flag accessible to the guest indicating that the specified
  2270. vCPU has been paused by the host userspace.
  2271. The host will set a flag in the pvclock structure that is checked from the
  2272. soft lockup watchdog. The flag is part of the pvclock structure that is
  2273. shared between guest and host, specifically the second bit of the flags
  2274. field of the pvclock_vcpu_time_info structure. It will be set exclusively by
  2275. the host and read/cleared exclusively by the guest. The guest operation of
  2276. checking and clearing the flag must be an atomic operation so
  2277. load-link/store-conditional, or equivalent must be used. There are two cases
  2278. where the guest will clear the flag: when the soft lockup watchdog timer resets
  2279. itself or when a soft lockup is detected. This ioctl can be called any time
  2280. after pausing the vcpu, but before it is resumed.
  2281. 4.71 KVM_SIGNAL_MSI
  2282. -------------------
  2283. :Capability: KVM_CAP_SIGNAL_MSI
  2284. :Architectures: x86 arm64
  2285. :Type: vm ioctl
  2286. :Parameters: struct kvm_msi (in)
  2287. :Returns: >0 on delivery, 0 if guest blocked the MSI, and -1 on error
  2288. Directly inject a MSI message. Only valid with in-kernel irqchip that handles
  2289. MSI messages.
  2290. ::
  2291. struct kvm_msi {
  2292. __u32 address_lo;
  2293. __u32 address_hi;
  2294. __u32 data;
  2295. __u32 flags;
  2296. __u32 devid;
  2297. __u8 pad[12];
  2298. };
  2299. flags:
  2300. KVM_MSI_VALID_DEVID: devid contains a valid value. The per-VM
  2301. KVM_CAP_MSI_DEVID capability advertises the requirement to provide
  2302. the device ID. If this capability is not available, userspace
  2303. should never set the KVM_MSI_VALID_DEVID flag as the ioctl might fail.
  2304. If KVM_MSI_VALID_DEVID is set, devid contains a unique device identifier
  2305. for the device that wrote the MSI message. For PCI, this is usually a
  2306. BDF identifier in the lower 16 bits.
  2307. On x86, address_hi is ignored unless the KVM_X2APIC_API_USE_32BIT_IDS
  2308. feature of KVM_CAP_X2APIC_API capability is enabled. If it is enabled,
  2309. address_hi bits 31-8 provide bits 31-8 of the destination id. Bits 7-0 of
  2310. address_hi must be zero.
  2311. 4.71 KVM_CREATE_PIT2
  2312. --------------------
  2313. :Capability: KVM_CAP_PIT2
  2314. :Architectures: x86
  2315. :Type: vm ioctl
  2316. :Parameters: struct kvm_pit_config (in)
  2317. :Returns: 0 on success, -1 on error
  2318. Creates an in-kernel device model for the i8254 PIT. This call is only valid
  2319. after enabling in-kernel irqchip support via KVM_CREATE_IRQCHIP. The following
  2320. parameters have to be passed::
  2321. struct kvm_pit_config {
  2322. __u32 flags;
  2323. __u32 pad[15];
  2324. };
  2325. Valid flags are::
  2326. #define KVM_PIT_SPEAKER_DUMMY 1 /* emulate speaker port stub */
  2327. PIT timer interrupts may use a per-VM kernel thread for injection. If it
  2328. exists, this thread will have a name of the following pattern::
  2329. kvm-pit/<owner-process-pid>
  2330. When running a guest with elevated priorities, the scheduling parameters of
  2331. this thread may have to be adjusted accordingly.
  2332. This IOCTL replaces the obsolete KVM_CREATE_PIT.
  2333. 4.72 KVM_GET_PIT2
  2334. -----------------
  2335. :Capability: KVM_CAP_PIT_STATE2
  2336. :Architectures: x86
  2337. :Type: vm ioctl
  2338. :Parameters: struct kvm_pit_state2 (out)
  2339. :Returns: 0 on success, -1 on error
  2340. Retrieves the state of the in-kernel PIT model. Only valid after
  2341. KVM_CREATE_PIT2. The state is returned in the following structure::
  2342. struct kvm_pit_state2 {
  2343. struct kvm_pit_channel_state channels[3];
  2344. __u32 flags;
  2345. __u32 reserved[9];
  2346. };
  2347. Valid flags are::
  2348. /* disable PIT in HPET legacy mode */
  2349. #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
  2350. /* speaker port data bit enabled */
  2351. #define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002
  2352. This IOCTL replaces the obsolete KVM_GET_PIT.
  2353. 4.73 KVM_SET_PIT2
  2354. -----------------
  2355. :Capability: KVM_CAP_PIT_STATE2
  2356. :Architectures: x86
  2357. :Type: vm ioctl
  2358. :Parameters: struct kvm_pit_state2 (in)
  2359. :Returns: 0 on success, -1 on error
  2360. Sets the state of the in-kernel PIT model. Only valid after KVM_CREATE_PIT2.
  2361. See KVM_GET_PIT2 for details on struct kvm_pit_state2.
  2362. This IOCTL replaces the obsolete KVM_SET_PIT.
  2363. 4.74 KVM_PPC_GET_SMMU_INFO
  2364. --------------------------
  2365. :Capability: KVM_CAP_PPC_GET_SMMU_INFO
  2366. :Architectures: powerpc
  2367. :Type: vm ioctl
  2368. :Parameters: None
  2369. :Returns: 0 on success, -1 on error
  2370. This populates and returns a structure describing the features of
  2371. the "Server" class MMU emulation supported by KVM.
  2372. This can in turn be used by userspace to generate the appropriate
  2373. device-tree properties for the guest operating system.
  2374. The structure contains some global information, followed by an
  2375. array of supported segment page sizes::
  2376. struct kvm_ppc_smmu_info {
  2377. __u64 flags;
  2378. __u32 slb_size;
  2379. __u32 pad;
  2380. struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
  2381. };
  2382. The supported flags are:
  2383. - KVM_PPC_PAGE_SIZES_REAL:
  2384. When that flag is set, guest page sizes must "fit" the backing
  2385. store page sizes. When not set, any page size in the list can
  2386. be used regardless of how they are backed by userspace.
  2387. - KVM_PPC_1T_SEGMENTS
  2388. The emulated MMU supports 1T segments in addition to the
  2389. standard 256M ones.
  2390. - KVM_PPC_NO_HASH
  2391. This flag indicates that HPT guests are not supported by KVM,
  2392. thus all guests must use radix MMU mode.
  2393. The "slb_size" field indicates how many SLB entries are supported
  2394. The "sps" array contains 8 entries indicating the supported base
  2395. page sizes for a segment in increasing order. Each entry is defined
  2396. as follow::
  2397. struct kvm_ppc_one_seg_page_size {
  2398. __u32 page_shift; /* Base page shift of segment (or 0) */
  2399. __u32 slb_enc; /* SLB encoding for BookS */
  2400. struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
  2401. };
  2402. An entry with a "page_shift" of 0 is unused. Because the array is
  2403. organized in increasing order, a lookup can stop when encountering
  2404. such an entry.
  2405. The "slb_enc" field provides the encoding to use in the SLB for the
  2406. page size. The bits are in positions such as the value can directly
  2407. be OR'ed into the "vsid" argument of the slbmte instruction.
  2408. The "enc" array is a list which for each of those segment base page
  2409. size provides the list of supported actual page sizes (which can be
  2410. only larger or equal to the base page size), along with the
  2411. corresponding encoding in the hash PTE. Similarly, the array is
  2412. 8 entries sorted by increasing sizes and an entry with a "0" shift
  2413. is an empty entry and a terminator::
  2414. struct kvm_ppc_one_page_size {
  2415. __u32 page_shift; /* Page shift (or 0) */
  2416. __u32 pte_enc; /* Encoding in the HPTE (>>12) */
  2417. };
  2418. The "pte_enc" field provides a value that can OR'ed into the hash
  2419. PTE's RPN field (ie, it needs to be shifted left by 12 to OR it
  2420. into the hash PTE second double word).
  2421. 4.75 KVM_IRQFD
  2422. --------------
  2423. :Capability: KVM_CAP_IRQFD
  2424. :Architectures: x86 s390 arm64
  2425. :Type: vm ioctl
  2426. :Parameters: struct kvm_irqfd (in)
  2427. :Returns: 0 on success, -1 on error
  2428. Allows setting an eventfd to directly trigger a guest interrupt.
  2429. kvm_irqfd.fd specifies the file descriptor to use as the eventfd and
  2430. kvm_irqfd.gsi specifies the irqchip pin toggled by this event. When
  2431. an event is triggered on the eventfd, an interrupt is injected into
  2432. the guest using the specified gsi pin. The irqfd is removed using
  2433. the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd
  2434. and kvm_irqfd.gsi.
  2435. With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify
  2436. mechanism allowing emulation of level-triggered, irqfd-based
  2437. interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an
  2438. additional eventfd in the kvm_irqfd.resamplefd field. When operating
  2439. in resample mode, posting of an interrupt through kvm_irq.fd asserts
  2440. the specified gsi in the irqchip. When the irqchip is resampled, such
  2441. as from an EOI, the gsi is de-asserted and the user is notified via
  2442. kvm_irqfd.resamplefd. It is the user's responsibility to re-queue
  2443. the interrupt if the device making use of it still requires service.
  2444. Note that closing the resamplefd is not sufficient to disable the
  2445. irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment
  2446. and need not be specified with KVM_IRQFD_FLAG_DEASSIGN.
  2447. On arm64, gsi routing being supported, the following can happen:
  2448. - in case no routing entry is associated to this gsi, injection fails
  2449. - in case the gsi is associated to an irqchip routing entry,
  2450. irqchip.pin + 32 corresponds to the injected SPI ID.
  2451. - in case the gsi is associated to an MSI routing entry, the MSI
  2452. message and device ID are translated into an LPI (support restricted
  2453. to GICv3 ITS in-kernel emulation).
  2454. 4.76 KVM_PPC_ALLOCATE_HTAB
  2455. --------------------------
  2456. :Capability: KVM_CAP_PPC_ALLOC_HTAB
  2457. :Architectures: powerpc
  2458. :Type: vm ioctl
  2459. :Parameters: Pointer to u32 containing hash table order (in/out)
  2460. :Returns: 0 on success, -1 on error
  2461. This requests the host kernel to allocate an MMU hash table for a
  2462. guest using the PAPR paravirtualization interface. This only does
  2463. anything if the kernel is configured to use the Book 3S HV style of
  2464. virtualization. Otherwise the capability doesn't exist and the ioctl
  2465. returns an ENOTTY error. The rest of this description assumes Book 3S
  2466. HV.
  2467. There must be no vcpus running when this ioctl is called; if there
  2468. are, it will do nothing and return an EBUSY error.
  2469. The parameter is a pointer to a 32-bit unsigned integer variable
  2470. containing the order (log base 2) of the desired size of the hash
  2471. table, which must be between 18 and 46. On successful return from the
  2472. ioctl, the value will not be changed by the kernel.
  2473. If no hash table has been allocated when any vcpu is asked to run
  2474. (with the KVM_RUN ioctl), the host kernel will allocate a
  2475. default-sized hash table (16 MB).
  2476. If this ioctl is called when a hash table has already been allocated,
  2477. with a different order from the existing hash table, the existing hash
  2478. table will be freed and a new one allocated. If this is ioctl is
  2479. called when a hash table has already been allocated of the same order
  2480. as specified, the kernel will clear out the existing hash table (zero
  2481. all HPTEs). In either case, if the guest is using the virtualized
  2482. real-mode area (VRMA) facility, the kernel will re-create the VMRA
  2483. HPTEs on the next KVM_RUN of any vcpu.
  2484. 4.77 KVM_S390_INTERRUPT
  2485. -----------------------
  2486. :Capability: basic
  2487. :Architectures: s390
  2488. :Type: vm ioctl, vcpu ioctl
  2489. :Parameters: struct kvm_s390_interrupt (in)
  2490. :Returns: 0 on success, -1 on error
  2491. Allows to inject an interrupt to the guest. Interrupts can be floating
  2492. (vm ioctl) or per cpu (vcpu ioctl), depending on the interrupt type.
  2493. Interrupt parameters are passed via kvm_s390_interrupt::
  2494. struct kvm_s390_interrupt {
  2495. __u32 type;
  2496. __u32 parm;
  2497. __u64 parm64;
  2498. };
  2499. type can be one of the following:
  2500. KVM_S390_SIGP_STOP (vcpu)
  2501. - sigp stop; optional flags in parm
  2502. KVM_S390_PROGRAM_INT (vcpu)
  2503. - program check; code in parm
  2504. KVM_S390_SIGP_SET_PREFIX (vcpu)
  2505. - sigp set prefix; prefix address in parm
  2506. KVM_S390_RESTART (vcpu)
  2507. - restart
  2508. KVM_S390_INT_CLOCK_COMP (vcpu)
  2509. - clock comparator interrupt
  2510. KVM_S390_INT_CPU_TIMER (vcpu)
  2511. - CPU timer interrupt
  2512. KVM_S390_INT_VIRTIO (vm)
  2513. - virtio external interrupt; external interrupt
  2514. parameters in parm and parm64
  2515. KVM_S390_INT_SERVICE (vm)
  2516. - sclp external interrupt; sclp parameter in parm
  2517. KVM_S390_INT_EMERGENCY (vcpu)
  2518. - sigp emergency; source cpu in parm
  2519. KVM_S390_INT_EXTERNAL_CALL (vcpu)
  2520. - sigp external call; source cpu in parm
  2521. KVM_S390_INT_IO(ai,cssid,ssid,schid) (vm)
  2522. - compound value to indicate an
  2523. I/O interrupt (ai - adapter interrupt; cssid,ssid,schid - subchannel);
  2524. I/O interruption parameters in parm (subchannel) and parm64 (intparm,
  2525. interruption subclass)
  2526. KVM_S390_MCHK (vm, vcpu)
  2527. - machine check interrupt; cr 14 bits in parm, machine check interrupt
  2528. code in parm64 (note that machine checks needing further payload are not
  2529. supported by this ioctl)
  2530. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  2531. 4.78 KVM_PPC_GET_HTAB_FD
  2532. ------------------------
  2533. :Capability: KVM_CAP_PPC_HTAB_FD
  2534. :Architectures: powerpc
  2535. :Type: vm ioctl
  2536. :Parameters: Pointer to struct kvm_get_htab_fd (in)
  2537. :Returns: file descriptor number (>= 0) on success, -1 on error
  2538. This returns a file descriptor that can be used either to read out the
  2539. entries in the guest's hashed page table (HPT), or to write entries to
  2540. initialize the HPT. The returned fd can only be written to if the
  2541. KVM_GET_HTAB_WRITE bit is set in the flags field of the argument, and
  2542. can only be read if that bit is clear. The argument struct looks like
  2543. this::
  2544. /* For KVM_PPC_GET_HTAB_FD */
  2545. struct kvm_get_htab_fd {
  2546. __u64 flags;
  2547. __u64 start_index;
  2548. __u64 reserved[2];
  2549. };
  2550. /* Values for kvm_get_htab_fd.flags */
  2551. #define KVM_GET_HTAB_BOLTED_ONLY ((__u64)0x1)
  2552. #define KVM_GET_HTAB_WRITE ((__u64)0x2)
  2553. The 'start_index' field gives the index in the HPT of the entry at
  2554. which to start reading. It is ignored when writing.
  2555. Reads on the fd will initially supply information about all
  2556. "interesting" HPT entries. Interesting entries are those with the
  2557. bolted bit set, if the KVM_GET_HTAB_BOLTED_ONLY bit is set, otherwise
  2558. all entries. When the end of the HPT is reached, the read() will
  2559. return. If read() is called again on the fd, it will start again from
  2560. the beginning of the HPT, but will only return HPT entries that have
  2561. changed since they were last read.
  2562. Data read or written is structured as a header (8 bytes) followed by a
  2563. series of valid HPT entries (16 bytes) each. The header indicates how
  2564. many valid HPT entries there are and how many invalid entries follow
  2565. the valid entries. The invalid entries are not represented explicitly
  2566. in the stream. The header format is::
  2567. struct kvm_get_htab_header {
  2568. __u32 index;
  2569. __u16 n_valid;
  2570. __u16 n_invalid;
  2571. };
  2572. Writes to the fd create HPT entries starting at the index given in the
  2573. header; first 'n_valid' valid entries with contents from the data
  2574. written, then 'n_invalid' invalid entries, invalidating any previously
  2575. valid entries found.
  2576. 4.79 KVM_CREATE_DEVICE
  2577. ----------------------
  2578. :Capability: KVM_CAP_DEVICE_CTRL
  2579. :Architectures: all
  2580. :Type: vm ioctl
  2581. :Parameters: struct kvm_create_device (in/out)
  2582. :Returns: 0 on success, -1 on error
  2583. Errors:
  2584. ====== =======================================================
  2585. ENODEV The device type is unknown or unsupported
  2586. EEXIST Device already created, and this type of device may not
  2587. be instantiated multiple times
  2588. ====== =======================================================
  2589. Other error conditions may be defined by individual device types or
  2590. have their standard meanings.
  2591. Creates an emulated device in the kernel. The file descriptor returned
  2592. in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
  2593. If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
  2594. device type is supported (not necessarily whether it can be created
  2595. in the current vm).
  2596. Individual devices should not define flags. Attributes should be used
  2597. for specifying any behavior that is not implied by the device type
  2598. number.
  2599. ::
  2600. struct kvm_create_device {
  2601. __u32 type; /* in: KVM_DEV_TYPE_xxx */
  2602. __u32 fd; /* out: device handle */
  2603. __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
  2604. };
  2605. 4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
  2606. --------------------------------------------
  2607. :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  2608. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  2609. KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device (no set)
  2610. :Architectures: x86, arm64, s390
  2611. :Type: device ioctl, vm ioctl, vcpu ioctl
  2612. :Parameters: struct kvm_device_attr
  2613. :Returns: 0 on success, -1 on error
  2614. Errors:
  2615. ===== =============================================================
  2616. ENXIO The group or attribute is unknown/unsupported for this device
  2617. or hardware support is missing.
  2618. EPERM The attribute cannot (currently) be accessed this way
  2619. (e.g. read-only attribute, or attribute that only makes
  2620. sense when the device is in a different state)
  2621. ===== =============================================================
  2622. Other error conditions may be defined by individual device types.
  2623. Gets/sets a specified piece of device configuration and/or state. The
  2624. semantics are device-specific. See individual device documentation in
  2625. the "devices" directory. As with ONE_REG, the size of the data
  2626. transferred is defined by the particular attribute.
  2627. ::
  2628. struct kvm_device_attr {
  2629. __u32 flags; /* no flags currently defined */
  2630. __u32 group; /* device-defined */
  2631. __u64 attr; /* group-defined */
  2632. __u64 addr; /* userspace address of attr data */
  2633. };
  2634. 4.81 KVM_HAS_DEVICE_ATTR
  2635. ------------------------
  2636. :Capability: KVM_CAP_DEVICE_CTRL, KVM_CAP_VM_ATTRIBUTES for vm device,
  2637. KVM_CAP_VCPU_ATTRIBUTES for vcpu device
  2638. KVM_CAP_SYS_ATTRIBUTES for system (/dev/kvm) device
  2639. :Type: device ioctl, vm ioctl, vcpu ioctl
  2640. :Parameters: struct kvm_device_attr
  2641. :Returns: 0 on success, -1 on error
  2642. Errors:
  2643. ===== =============================================================
  2644. ENXIO The group or attribute is unknown/unsupported for this device
  2645. or hardware support is missing.
  2646. ===== =============================================================
  2647. Tests whether a device supports a particular attribute. A successful
  2648. return indicates the attribute is implemented. It does not necessarily
  2649. indicate that the attribute can be read or written in the device's
  2650. current state. "addr" is ignored.
  2651. .. _KVM_ARM_VCPU_INIT:
  2652. 4.82 KVM_ARM_VCPU_INIT
  2653. ----------------------
  2654. :Capability: basic
  2655. :Architectures: arm64
  2656. :Type: vcpu ioctl
  2657. :Parameters: struct kvm_vcpu_init (in)
  2658. :Returns: 0 on success; -1 on error
  2659. Errors:
  2660. ====== =================================================================
  2661. EINVAL the target is unknown, or the combination of features is invalid.
  2662. ENOENT a features bit specified is unknown.
  2663. ====== =================================================================
  2664. This tells KVM what type of CPU to present to the guest, and what
  2665. optional features it should have. This will cause a reset of the cpu
  2666. registers to their initial values. If this is not called, KVM_RUN will
  2667. return ENOEXEC for that vcpu.
  2668. The initial values are defined as:
  2669. - Processor state:
  2670. * AArch64: EL1h, D, A, I and F bits set. All other bits
  2671. are cleared.
  2672. * AArch32: SVC, A, I and F bits set. All other bits are
  2673. cleared.
  2674. - General Purpose registers, including PC and SP: set to 0
  2675. - FPSIMD/NEON registers: set to 0
  2676. - SVE registers: set to 0
  2677. - System registers: Reset to their architecturally defined
  2678. values as for a warm reset to EL1 (resp. SVC)
  2679. Note that because some registers reflect machine topology, all vcpus
  2680. should be created before this ioctl is invoked.
  2681. Userspace can call this function multiple times for a given vcpu, including
  2682. after the vcpu has been run. This will reset the vcpu to its initial
  2683. state. All calls to this function after the initial call must use the same
  2684. target and same set of feature flags, otherwise EINVAL will be returned.
  2685. Possible features:
  2686. - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state.
  2687. Depends on KVM_CAP_ARM_PSCI. If not set, the CPU will be powered on
  2688. and execute guest code when KVM_RUN is called.
  2689. - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
  2690. Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
  2691. - KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 (or a future revision
  2692. backward compatible with v0.2) for the CPU.
  2693. Depends on KVM_CAP_ARM_PSCI_0_2.
  2694. - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
  2695. Depends on KVM_CAP_ARM_PMU_V3.
  2696. - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication
  2697. for arm64 only.
  2698. Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS.
  2699. If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
  2700. both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
  2701. KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
  2702. requested.
  2703. - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication
  2704. for arm64 only.
  2705. Depends on KVM_CAP_ARM_PTRAUTH_GENERIC.
  2706. If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
  2707. both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
  2708. KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
  2709. requested.
  2710. - KVM_ARM_VCPU_SVE: Enables SVE for the CPU (arm64 only).
  2711. Depends on KVM_CAP_ARM_SVE.
  2712. Requires KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
  2713. * After KVM_ARM_VCPU_INIT:
  2714. - KVM_REG_ARM64_SVE_VLS may be read using KVM_GET_ONE_REG: the
  2715. initial value of this pseudo-register indicates the best set of
  2716. vector lengths possible for a vcpu on this host.
  2717. * Before KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
  2718. - KVM_RUN and KVM_GET_REG_LIST are not available;
  2719. - KVM_GET_ONE_REG and KVM_SET_ONE_REG cannot be used to access
  2720. the scalable architectural SVE registers
  2721. KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() or
  2722. KVM_REG_ARM64_SVE_FFR;
  2723. - KVM_REG_ARM64_SVE_VLS may optionally be written using
  2724. KVM_SET_ONE_REG, to modify the set of vector lengths available
  2725. for the vcpu.
  2726. * After KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
  2727. - the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can
  2728. no longer be written using KVM_SET_ONE_REG.
  2729. 4.83 KVM_ARM_PREFERRED_TARGET
  2730. -----------------------------
  2731. :Capability: basic
  2732. :Architectures: arm64
  2733. :Type: vm ioctl
  2734. :Parameters: struct kvm_vcpu_init (out)
  2735. :Returns: 0 on success; -1 on error
  2736. Errors:
  2737. ====== ==========================================
  2738. ENODEV no preferred target available for the host
  2739. ====== ==========================================
  2740. This queries KVM for preferred CPU target type which can be emulated
  2741. by KVM on underlying host.
  2742. The ioctl returns struct kvm_vcpu_init instance containing information
  2743. about preferred CPU target type and recommended features for it. The
  2744. kvm_vcpu_init->features bitmap returned will have feature bits set if
  2745. the preferred target recommends setting these features, but this is
  2746. not mandatory.
  2747. The information returned by this ioctl can be used to prepare an instance
  2748. of struct kvm_vcpu_init for KVM_ARM_VCPU_INIT ioctl which will result in
  2749. VCPU matching underlying host.
  2750. 4.84 KVM_GET_REG_LIST
  2751. ---------------------
  2752. :Capability: basic
  2753. :Architectures: arm64, mips, riscv
  2754. :Type: vcpu ioctl
  2755. :Parameters: struct kvm_reg_list (in/out)
  2756. :Returns: 0 on success; -1 on error
  2757. Errors:
  2758. ===== ==============================================================
  2759. E2BIG the reg index list is too big to fit in the array specified by
  2760. the user (the number required will be written into n).
  2761. ===== ==============================================================
  2762. ::
  2763. struct kvm_reg_list {
  2764. __u64 n; /* number of registers in reg[] */
  2765. __u64 reg[0];
  2766. };
  2767. This ioctl returns the guest registers that are supported for the
  2768. KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
  2769. 4.85 KVM_ARM_SET_DEVICE_ADDR (deprecated)
  2770. -----------------------------------------
  2771. :Capability: KVM_CAP_ARM_SET_DEVICE_ADDR
  2772. :Architectures: arm64
  2773. :Type: vm ioctl
  2774. :Parameters: struct kvm_arm_device_address (in)
  2775. :Returns: 0 on success, -1 on error
  2776. Errors:
  2777. ====== ============================================
  2778. ENODEV The device id is unknown
  2779. ENXIO Device not supported on current system
  2780. EEXIST Address already set
  2781. E2BIG Address outside guest physical address space
  2782. EBUSY Address overlaps with other device range
  2783. ====== ============================================
  2784. ::
  2785. struct kvm_arm_device_addr {
  2786. __u64 id;
  2787. __u64 addr;
  2788. };
  2789. Specify a device address in the guest's physical address space where guests
  2790. can access emulated or directly exposed devices, which the host kernel needs
  2791. to know about. The id field is an architecture specific identifier for a
  2792. specific device.
  2793. arm64 divides the id field into two parts, a device id and an
  2794. address type id specific to the individual device::
  2795. bits: | 63 ... 32 | 31 ... 16 | 15 ... 0 |
  2796. field: | 0x00000000 | device id | addr type id |
  2797. arm64 currently only require this when using the in-kernel GIC
  2798. support for the hardware VGIC features, using KVM_ARM_DEVICE_VGIC_V2
  2799. as the device id. When setting the base address for the guest's
  2800. mapping of the VGIC virtual CPU and distributor interface, the ioctl
  2801. must be called after calling KVM_CREATE_IRQCHIP, but before calling
  2802. KVM_RUN on any of the VCPUs. Calling this ioctl twice for any of the
  2803. base addresses will return -EEXIST.
  2804. Note, this IOCTL is deprecated and the more flexible SET/GET_DEVICE_ATTR API
  2805. should be used instead.
  2806. 4.86 KVM_PPC_RTAS_DEFINE_TOKEN
  2807. ------------------------------
  2808. :Capability: KVM_CAP_PPC_RTAS
  2809. :Architectures: ppc
  2810. :Type: vm ioctl
  2811. :Parameters: struct kvm_rtas_token_args
  2812. :Returns: 0 on success, -1 on error
  2813. Defines a token value for a RTAS (Run Time Abstraction Services)
  2814. service in order to allow it to be handled in the kernel. The
  2815. argument struct gives the name of the service, which must be the name
  2816. of a service that has a kernel-side implementation. If the token
  2817. value is non-zero, it will be associated with that service, and
  2818. subsequent RTAS calls by the guest specifying that token will be
  2819. handled by the kernel. If the token value is 0, then any token
  2820. associated with the service will be forgotten, and subsequent RTAS
  2821. calls by the guest for that service will be passed to userspace to be
  2822. handled.
  2823. 4.87 KVM_SET_GUEST_DEBUG
  2824. ------------------------
  2825. :Capability: KVM_CAP_SET_GUEST_DEBUG
  2826. :Architectures: x86, s390, ppc, arm64
  2827. :Type: vcpu ioctl
  2828. :Parameters: struct kvm_guest_debug (in)
  2829. :Returns: 0 on success; -1 on error
  2830. ::
  2831. struct kvm_guest_debug {
  2832. __u32 control;
  2833. __u32 pad;
  2834. struct kvm_guest_debug_arch arch;
  2835. };
  2836. Set up the processor specific debug registers and configure vcpu for
  2837. handling guest debug events. There are two parts to the structure, the
  2838. first a control bitfield indicates the type of debug events to handle
  2839. when running. Common control bits are:
  2840. - KVM_GUESTDBG_ENABLE: guest debugging is enabled
  2841. - KVM_GUESTDBG_SINGLESTEP: the next run should single-step
  2842. The top 16 bits of the control field are architecture specific control
  2843. flags which can include the following:
  2844. - KVM_GUESTDBG_USE_SW_BP: using software breakpoints [x86, arm64]
  2845. - KVM_GUESTDBG_USE_HW_BP: using hardware breakpoints [x86, s390]
  2846. - KVM_GUESTDBG_USE_HW: using hardware debug events [arm64]
  2847. - KVM_GUESTDBG_INJECT_DB: inject DB type exception [x86]
  2848. - KVM_GUESTDBG_INJECT_BP: inject BP type exception [x86]
  2849. - KVM_GUESTDBG_EXIT_PENDING: trigger an immediate guest exit [s390]
  2850. - KVM_GUESTDBG_BLOCKIRQ: avoid injecting interrupts/NMI/SMI [x86]
  2851. For example KVM_GUESTDBG_USE_SW_BP indicates that software breakpoints
  2852. are enabled in memory so we need to ensure breakpoint exceptions are
  2853. correctly trapped and the KVM run loop exits at the breakpoint and not
  2854. running off into the normal guest vector. For KVM_GUESTDBG_USE_HW_BP
  2855. we need to ensure the guest vCPUs architecture specific registers are
  2856. updated to the correct (supplied) values.
  2857. The second part of the structure is architecture specific and
  2858. typically contains a set of debug registers.
  2859. For arm64 the number of debug registers is implementation defined and
  2860. can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and
  2861. KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number
  2862. indicating the number of supported registers.
  2863. For ppc, the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability indicates whether
  2864. the single-step debug event (KVM_GUESTDBG_SINGLESTEP) is supported.
  2865. Also when supported, KVM_CAP_SET_GUEST_DEBUG2 capability indicates the
  2866. supported KVM_GUESTDBG_* bits in the control field.
  2867. When debug events exit the main run loop with the reason
  2868. KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run
  2869. structure containing architecture specific debug information.
  2870. 4.88 KVM_GET_EMULATED_CPUID
  2871. ---------------------------
  2872. :Capability: KVM_CAP_EXT_EMUL_CPUID
  2873. :Architectures: x86
  2874. :Type: system ioctl
  2875. :Parameters: struct kvm_cpuid2 (in/out)
  2876. :Returns: 0 on success, -1 on error
  2877. ::
  2878. struct kvm_cpuid2 {
  2879. __u32 nent;
  2880. __u32 flags;
  2881. struct kvm_cpuid_entry2 entries[0];
  2882. };
  2883. The member 'flags' is used for passing flags from userspace.
  2884. ::
  2885. #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
  2886. #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1) /* deprecated */
  2887. #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2) /* deprecated */
  2888. struct kvm_cpuid_entry2 {
  2889. __u32 function;
  2890. __u32 index;
  2891. __u32 flags;
  2892. __u32 eax;
  2893. __u32 ebx;
  2894. __u32 ecx;
  2895. __u32 edx;
  2896. __u32 padding[3];
  2897. };
  2898. This ioctl returns x86 cpuid features which are emulated by
  2899. kvm.Userspace can use the information returned by this ioctl to query
  2900. which features are emulated by kvm instead of being present natively.
  2901. Userspace invokes KVM_GET_EMULATED_CPUID by passing a kvm_cpuid2
  2902. structure with the 'nent' field indicating the number of entries in
  2903. the variable-size array 'entries'. If the number of entries is too low
  2904. to describe the cpu capabilities, an error (E2BIG) is returned. If the
  2905. number is too high, the 'nent' field is adjusted and an error (ENOMEM)
  2906. is returned. If the number is just right, the 'nent' field is adjusted
  2907. to the number of valid entries in the 'entries' array, which is then
  2908. filled.
  2909. The entries returned are the set CPUID bits of the respective features
  2910. which kvm emulates, as returned by the CPUID instruction, with unknown
  2911. or unsupported feature bits cleared.
  2912. Features like x2apic, for example, may not be present in the host cpu
  2913. but are exposed by kvm in KVM_GET_SUPPORTED_CPUID because they can be
  2914. emulated efficiently and thus not included here.
  2915. The fields in each entry are defined as follows:
  2916. function:
  2917. the eax value used to obtain the entry
  2918. index:
  2919. the ecx value used to obtain the entry (for entries that are
  2920. affected by ecx)
  2921. flags:
  2922. an OR of zero or more of the following:
  2923. KVM_CPUID_FLAG_SIGNIFCANT_INDEX:
  2924. if the index field is valid
  2925. eax, ebx, ecx, edx:
  2926. the values returned by the cpuid instruction for
  2927. this function/index combination
  2928. 4.89 KVM_S390_MEM_OP
  2929. --------------------
  2930. :Capability: KVM_CAP_S390_MEM_OP, KVM_CAP_S390_PROTECTED, KVM_CAP_S390_MEM_OP_EXTENSION
  2931. :Architectures: s390
  2932. :Type: vm ioctl, vcpu ioctl
  2933. :Parameters: struct kvm_s390_mem_op (in)
  2934. :Returns: = 0 on success,
  2935. < 0 on generic error (e.g. -EFAULT or -ENOMEM),
  2936. 16 bit program exception code if the access causes such an exception
  2937. Read or write data from/to the VM's memory.
  2938. The KVM_CAP_S390_MEM_OP_EXTENSION capability specifies what functionality is
  2939. supported.
  2940. Parameters are specified via the following structure::
  2941. struct kvm_s390_mem_op {
  2942. __u64 gaddr; /* the guest address */
  2943. __u64 flags; /* flags */
  2944. __u32 size; /* amount of bytes */
  2945. __u32 op; /* type of operation */
  2946. __u64 buf; /* buffer in userspace */
  2947. union {
  2948. struct {
  2949. __u8 ar; /* the access register number */
  2950. __u8 key; /* access key, ignored if flag unset */
  2951. __u8 pad1[6]; /* ignored */
  2952. __u64 old_addr; /* ignored if flag unset */
  2953. };
  2954. __u32 sida_offset; /* offset into the sida */
  2955. __u8 reserved[32]; /* ignored */
  2956. };
  2957. };
  2958. The start address of the memory region has to be specified in the "gaddr"
  2959. field, and the length of the region in the "size" field (which must not
  2960. be 0). The maximum value for "size" can be obtained by checking the
  2961. KVM_CAP_S390_MEM_OP capability. "buf" is the buffer supplied by the
  2962. userspace application where the read data should be written to for
  2963. a read access, or where the data that should be written is stored for
  2964. a write access. The "reserved" field is meant for future extensions.
  2965. Reserved and unused values are ignored. Future extension that add members must
  2966. introduce new flags.
  2967. The type of operation is specified in the "op" field. Flags modifying
  2968. their behavior can be set in the "flags" field. Undefined flag bits must
  2969. be set to 0.
  2970. Possible operations are:
  2971. * ``KVM_S390_MEMOP_LOGICAL_READ``
  2972. * ``KVM_S390_MEMOP_LOGICAL_WRITE``
  2973. * ``KVM_S390_MEMOP_ABSOLUTE_READ``
  2974. * ``KVM_S390_MEMOP_ABSOLUTE_WRITE``
  2975. * ``KVM_S390_MEMOP_SIDA_READ``
  2976. * ``KVM_S390_MEMOP_SIDA_WRITE``
  2977. * ``KVM_S390_MEMOP_ABSOLUTE_CMPXCHG``
  2978. Logical read/write:
  2979. ^^^^^^^^^^^^^^^^^^^
  2980. Access logical memory, i.e. translate the given guest address to an absolute
  2981. address given the state of the VCPU and use the absolute address as target of
  2982. the access. "ar" designates the access register number to be used; the valid
  2983. range is 0..15.
  2984. Logical accesses are permitted for the VCPU ioctl only.
  2985. Logical accesses are permitted for non-protected guests only.
  2986. Supported flags:
  2987. * ``KVM_S390_MEMOP_F_CHECK_ONLY``
  2988. * ``KVM_S390_MEMOP_F_INJECT_EXCEPTION``
  2989. * ``KVM_S390_MEMOP_F_SKEY_PROTECTION``
  2990. The KVM_S390_MEMOP_F_CHECK_ONLY flag can be set to check whether the
  2991. corresponding memory access would cause an access exception; however,
  2992. no actual access to the data in memory at the destination is performed.
  2993. In this case, "buf" is unused and can be NULL.
  2994. In case an access exception occurred during the access (or would occur
  2995. in case of KVM_S390_MEMOP_F_CHECK_ONLY), the ioctl returns a positive
  2996. error number indicating the type of exception. This exception is also
  2997. raised directly at the corresponding VCPU if the flag
  2998. KVM_S390_MEMOP_F_INJECT_EXCEPTION is set.
  2999. On protection exceptions, unless specified otherwise, the injected
  3000. translation-exception identifier (TEID) indicates suppression.
  3001. If the KVM_S390_MEMOP_F_SKEY_PROTECTION flag is set, storage key
  3002. protection is also in effect and may cause exceptions if accesses are
  3003. prohibited given the access key designated by "key"; the valid range is 0..15.
  3004. KVM_S390_MEMOP_F_SKEY_PROTECTION is available if KVM_CAP_S390_MEM_OP_EXTENSION
  3005. is > 0.
  3006. Since the accessed memory may span multiple pages and those pages might have
  3007. different storage keys, it is possible that a protection exception occurs
  3008. after memory has been modified. In this case, if the exception is injected,
  3009. the TEID does not indicate suppression.
  3010. Absolute read/write:
  3011. ^^^^^^^^^^^^^^^^^^^^
  3012. Access absolute memory. This operation is intended to be used with the
  3013. KVM_S390_MEMOP_F_SKEY_PROTECTION flag, to allow accessing memory and performing
  3014. the checks required for storage key protection as one operation (as opposed to
  3015. user space getting the storage keys, performing the checks, and accessing
  3016. memory thereafter, which could lead to a delay between check and access).
  3017. Absolute accesses are permitted for the VM ioctl if KVM_CAP_S390_MEM_OP_EXTENSION
  3018. has the KVM_S390_MEMOP_EXTENSION_CAP_BASE bit set.
  3019. Currently absolute accesses are not permitted for VCPU ioctls.
  3020. Absolute accesses are permitted for non-protected guests only.
  3021. Supported flags:
  3022. * ``KVM_S390_MEMOP_F_CHECK_ONLY``
  3023. * ``KVM_S390_MEMOP_F_SKEY_PROTECTION``
  3024. The semantics of the flags common with logical accesses are as for logical
  3025. accesses.
  3026. Absolute cmpxchg:
  3027. ^^^^^^^^^^^^^^^^^
  3028. Perform cmpxchg on absolute guest memory. Intended for use with the
  3029. KVM_S390_MEMOP_F_SKEY_PROTECTION flag.
  3030. Instead of doing an unconditional write, the access occurs only if the target
  3031. location contains the value pointed to by "old_addr".
  3032. This is performed as an atomic cmpxchg with the length specified by the "size"
  3033. parameter. "size" must be a power of two up to and including 16.
  3034. If the exchange did not take place because the target value doesn't match the
  3035. old value, the value "old_addr" points to is replaced by the target value.
  3036. User space can tell if an exchange took place by checking if this replacement
  3037. occurred. The cmpxchg op is permitted for the VM ioctl if
  3038. KVM_CAP_S390_MEM_OP_EXTENSION has flag KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG set.
  3039. Supported flags:
  3040. * ``KVM_S390_MEMOP_F_SKEY_PROTECTION``
  3041. SIDA read/write:
  3042. ^^^^^^^^^^^^^^^^
  3043. Access the secure instruction data area which contains memory operands necessary
  3044. for instruction emulation for protected guests.
  3045. SIDA accesses are available if the KVM_CAP_S390_PROTECTED capability is available.
  3046. SIDA accesses are permitted for the VCPU ioctl only.
  3047. SIDA accesses are permitted for protected guests only.
  3048. No flags are supported.
  3049. 4.90 KVM_S390_GET_SKEYS
  3050. -----------------------
  3051. :Capability: KVM_CAP_S390_SKEYS
  3052. :Architectures: s390
  3053. :Type: vm ioctl
  3054. :Parameters: struct kvm_s390_skeys
  3055. :Returns: 0 on success, KVM_S390_GET_SKEYS_NONE if guest is not using storage
  3056. keys, negative value on error
  3057. This ioctl is used to get guest storage key values on the s390
  3058. architecture. The ioctl takes parameters via the kvm_s390_skeys struct::
  3059. struct kvm_s390_skeys {
  3060. __u64 start_gfn;
  3061. __u64 count;
  3062. __u64 skeydata_addr;
  3063. __u32 flags;
  3064. __u32 reserved[9];
  3065. };
  3066. The start_gfn field is the number of the first guest frame whose storage keys
  3067. you want to get.
  3068. The count field is the number of consecutive frames (starting from start_gfn)
  3069. whose storage keys to get. The count field must be at least 1 and the maximum
  3070. allowed value is defined as KVM_S390_SKEYS_MAX. Values outside this range
  3071. will cause the ioctl to return -EINVAL.
  3072. The skeydata_addr field is the address to a buffer large enough to hold count
  3073. bytes. This buffer will be filled with storage key data by the ioctl.
  3074. 4.91 KVM_S390_SET_SKEYS
  3075. -----------------------
  3076. :Capability: KVM_CAP_S390_SKEYS
  3077. :Architectures: s390
  3078. :Type: vm ioctl
  3079. :Parameters: struct kvm_s390_skeys
  3080. :Returns: 0 on success, negative value on error
  3081. This ioctl is used to set guest storage key values on the s390
  3082. architecture. The ioctl takes parameters via the kvm_s390_skeys struct.
  3083. See section on KVM_S390_GET_SKEYS for struct definition.
  3084. The start_gfn field is the number of the first guest frame whose storage keys
  3085. you want to set.
  3086. The count field is the number of consecutive frames (starting from start_gfn)
  3087. whose storage keys to get. The count field must be at least 1 and the maximum
  3088. allowed value is defined as KVM_S390_SKEYS_MAX. Values outside this range
  3089. will cause the ioctl to return -EINVAL.
  3090. The skeydata_addr field is the address to a buffer containing count bytes of
  3091. storage keys. Each byte in the buffer will be set as the storage key for a
  3092. single frame starting at start_gfn for count frames.
  3093. Note: If any architecturally invalid key value is found in the given data then
  3094. the ioctl will return -EINVAL.
  3095. 4.92 KVM_S390_IRQ
  3096. -----------------
  3097. :Capability: KVM_CAP_S390_INJECT_IRQ
  3098. :Architectures: s390
  3099. :Type: vcpu ioctl
  3100. :Parameters: struct kvm_s390_irq (in)
  3101. :Returns: 0 on success, -1 on error
  3102. Errors:
  3103. ====== =================================================================
  3104. EINVAL interrupt type is invalid
  3105. type is KVM_S390_SIGP_STOP and flag parameter is invalid value,
  3106. type is KVM_S390_INT_EXTERNAL_CALL and code is bigger
  3107. than the maximum of VCPUs
  3108. EBUSY type is KVM_S390_SIGP_SET_PREFIX and vcpu is not stopped,
  3109. type is KVM_S390_SIGP_STOP and a stop irq is already pending,
  3110. type is KVM_S390_INT_EXTERNAL_CALL and an external call interrupt
  3111. is already pending
  3112. ====== =================================================================
  3113. Allows to inject an interrupt to the guest.
  3114. Using struct kvm_s390_irq as a parameter allows
  3115. to inject additional payload which is not
  3116. possible via KVM_S390_INTERRUPT.
  3117. Interrupt parameters are passed via kvm_s390_irq::
  3118. struct kvm_s390_irq {
  3119. __u64 type;
  3120. union {
  3121. struct kvm_s390_io_info io;
  3122. struct kvm_s390_ext_info ext;
  3123. struct kvm_s390_pgm_info pgm;
  3124. struct kvm_s390_emerg_info emerg;
  3125. struct kvm_s390_extcall_info extcall;
  3126. struct kvm_s390_prefix_info prefix;
  3127. struct kvm_s390_stop_info stop;
  3128. struct kvm_s390_mchk_info mchk;
  3129. char reserved[64];
  3130. } u;
  3131. };
  3132. type can be one of the following:
  3133. - KVM_S390_SIGP_STOP - sigp stop; parameter in .stop
  3134. - KVM_S390_PROGRAM_INT - program check; parameters in .pgm
  3135. - KVM_S390_SIGP_SET_PREFIX - sigp set prefix; parameters in .prefix
  3136. - KVM_S390_RESTART - restart; no parameters
  3137. - KVM_S390_INT_CLOCK_COMP - clock comparator interrupt; no parameters
  3138. - KVM_S390_INT_CPU_TIMER - CPU timer interrupt; no parameters
  3139. - KVM_S390_INT_EMERGENCY - sigp emergency; parameters in .emerg
  3140. - KVM_S390_INT_EXTERNAL_CALL - sigp external call; parameters in .extcall
  3141. - KVM_S390_MCHK - machine check interrupt; parameters in .mchk
  3142. This is an asynchronous vcpu ioctl and can be invoked from any thread.
  3143. 4.94 KVM_S390_GET_IRQ_STATE
  3144. ---------------------------
  3145. :Capability: KVM_CAP_S390_IRQ_STATE
  3146. :Architectures: s390
  3147. :Type: vcpu ioctl
  3148. :Parameters: struct kvm_s390_irq_state (out)
  3149. :Returns: >= number of bytes copied into buffer,
  3150. -EINVAL if buffer size is 0,
  3151. -ENOBUFS if buffer size is too small to fit all pending interrupts,
  3152. -EFAULT if the buffer address was invalid
  3153. This ioctl allows userspace to retrieve the complete state of all currently
  3154. pending interrupts in a single buffer. Use cases include migration
  3155. and introspection. The parameter structure contains the address of a
  3156. userspace buffer and its length::
  3157. struct kvm_s390_irq_state {
  3158. __u64 buf;
  3159. __u32 flags; /* will stay unused for compatibility reasons */
  3160. __u32 len;
  3161. __u32 reserved[4]; /* will stay unused for compatibility reasons */
  3162. };
  3163. Userspace passes in the above struct and for each pending interrupt a
  3164. struct kvm_s390_irq is copied to the provided buffer.
  3165. The structure contains a flags and a reserved field for future extensions. As
  3166. the kernel never checked for flags == 0 and QEMU never pre-zeroed flags and
  3167. reserved, these fields can not be used in the future without breaking
  3168. compatibility.
  3169. If -ENOBUFS is returned the buffer provided was too small and userspace
  3170. may retry with a bigger buffer.
  3171. 4.95 KVM_S390_SET_IRQ_STATE
  3172. ---------------------------
  3173. :Capability: KVM_CAP_S390_IRQ_STATE
  3174. :Architectures: s390
  3175. :Type: vcpu ioctl
  3176. :Parameters: struct kvm_s390_irq_state (in)
  3177. :Returns: 0 on success,
  3178. -EFAULT if the buffer address was invalid,
  3179. -EINVAL for an invalid buffer length (see below),
  3180. -EBUSY if there were already interrupts pending,
  3181. errors occurring when actually injecting the
  3182. interrupt. See KVM_S390_IRQ.
  3183. This ioctl allows userspace to set the complete state of all cpu-local
  3184. interrupts currently pending for the vcpu. It is intended for restoring
  3185. interrupt state after a migration. The input parameter is a userspace buffer
  3186. containing a struct kvm_s390_irq_state::
  3187. struct kvm_s390_irq_state {
  3188. __u64 buf;
  3189. __u32 flags; /* will stay unused for compatibility reasons */
  3190. __u32 len;
  3191. __u32 reserved[4]; /* will stay unused for compatibility reasons */
  3192. };
  3193. The restrictions for flags and reserved apply as well.
  3194. (see KVM_S390_GET_IRQ_STATE)
  3195. The userspace memory referenced by buf contains a struct kvm_s390_irq
  3196. for each interrupt to be injected into the guest.
  3197. If one of the interrupts could not be injected for some reason the
  3198. ioctl aborts.
  3199. len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0
  3200. and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq),
  3201. which is the maximum number of possibly pending cpu-local interrupts.
  3202. 4.96 KVM_SMI
  3203. ------------
  3204. :Capability: KVM_CAP_X86_SMM
  3205. :Architectures: x86
  3206. :Type: vcpu ioctl
  3207. :Parameters: none
  3208. :Returns: 0 on success, -1 on error
  3209. Queues an SMI on the thread's vcpu.
  3210. 4.97 KVM_X86_SET_MSR_FILTER
  3211. ----------------------------
  3212. :Capability: KVM_CAP_X86_MSR_FILTER
  3213. :Architectures: x86
  3214. :Type: vm ioctl
  3215. :Parameters: struct kvm_msr_filter
  3216. :Returns: 0 on success, < 0 on error
  3217. ::
  3218. struct kvm_msr_filter_range {
  3219. #define KVM_MSR_FILTER_READ (1 << 0)
  3220. #define KVM_MSR_FILTER_WRITE (1 << 1)
  3221. __u32 flags;
  3222. __u32 nmsrs; /* number of msrs in bitmap */
  3223. __u32 base; /* MSR index the bitmap starts at */
  3224. __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */
  3225. };
  3226. #define KVM_MSR_FILTER_MAX_RANGES 16
  3227. struct kvm_msr_filter {
  3228. #define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
  3229. #define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0)
  3230. __u32 flags;
  3231. struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
  3232. };
  3233. flags values for ``struct kvm_msr_filter_range``:
  3234. ``KVM_MSR_FILTER_READ``
  3235. Filter read accesses to MSRs using the given bitmap. A 0 in the bitmap
  3236. indicates that read accesses should be denied, while a 1 indicates that
  3237. a read for a particular MSR should be allowed regardless of the default
  3238. filter action.
  3239. ``KVM_MSR_FILTER_WRITE``
  3240. Filter write accesses to MSRs using the given bitmap. A 0 in the bitmap
  3241. indicates that write accesses should be denied, while a 1 indicates that
  3242. a write for a particular MSR should be allowed regardless of the default
  3243. filter action.
  3244. flags values for ``struct kvm_msr_filter``:
  3245. ``KVM_MSR_FILTER_DEFAULT_ALLOW``
  3246. If no filter range matches an MSR index that is getting accessed, KVM will
  3247. allow accesses to all MSRs by default.
  3248. ``KVM_MSR_FILTER_DEFAULT_DENY``
  3249. If no filter range matches an MSR index that is getting accessed, KVM will
  3250. deny accesses to all MSRs by default.
  3251. This ioctl allows userspace to define up to 16 bitmaps of MSR ranges to deny
  3252. guest MSR accesses that would normally be allowed by KVM. If an MSR is not
  3253. covered by a specific range, the "default" filtering behavior applies. Each
  3254. bitmap range covers MSRs from [base .. base+nmsrs).
  3255. If an MSR access is denied by userspace, the resulting KVM behavior depends on
  3256. whether or not KVM_CAP_X86_USER_SPACE_MSR's KVM_MSR_EXIT_REASON_FILTER is
  3257. enabled. If KVM_MSR_EXIT_REASON_FILTER is enabled, KVM will exit to userspace
  3258. on denied accesses, i.e. userspace effectively intercepts the MSR access. If
  3259. KVM_MSR_EXIT_REASON_FILTER is not enabled, KVM will inject a #GP into the guest
  3260. on denied accesses. Note, if an MSR access is denied during emulation of MSR
  3261. load/stores during VMX transitions, KVM ignores KVM_MSR_EXIT_REASON_FILTER.
  3262. See the below warning for full details.
  3263. If an MSR access is allowed by userspace, KVM will emulate and/or virtualize
  3264. the access in accordance with the vCPU model. Note, KVM may still ultimately
  3265. inject a #GP if an access is allowed by userspace, e.g. if KVM doesn't support
  3266. the MSR, or to follow architectural behavior for the MSR.
  3267. By default, KVM operates in KVM_MSR_FILTER_DEFAULT_ALLOW mode with no MSR range
  3268. filters.
  3269. Calling this ioctl with an empty set of ranges (all nmsrs == 0) disables MSR
  3270. filtering. In that mode, ``KVM_MSR_FILTER_DEFAULT_DENY`` is invalid and causes
  3271. an error.
  3272. .. warning::
  3273. MSR accesses that are side effects of instruction execution (emulated or
  3274. native) are not filtered as hardware does not honor MSR bitmaps outside of
  3275. RDMSR and WRMSR, and KVM mimics that behavior when emulating instructions
  3276. to avoid pointless divergence from hardware. E.g. RDPID reads MSR_TSC_AUX,
  3277. SYSENTER reads the SYSENTER MSRs, etc.
  3278. MSRs that are loaded/stored via dedicated VMCS fields are not filtered as
  3279. part of VM-Enter/VM-Exit emulation.
  3280. MSRs that are loaded/store via VMX's load/store lists _are_ filtered as part
  3281. of VM-Enter/VM-Exit emulation. If an MSR access is denied on VM-Enter, KVM
  3282. synthesizes a consistency check VM-Exit(EXIT_REASON_MSR_LOAD_FAIL). If an
  3283. MSR access is denied on VM-Exit, KVM synthesizes a VM-Abort. In short, KVM
  3284. extends Intel's architectural list of MSRs that cannot be loaded/saved via
  3285. the VM-Enter/VM-Exit MSR list. It is platform owner's responsibility to
  3286. to communicate any such restrictions to their end users.
  3287. x2APIC MSR accesses cannot be filtered (KVM silently ignores filters that
  3288. cover any x2APIC MSRs).
  3289. Note, invoking this ioctl while a vCPU is running is inherently racy. However,
  3290. KVM does guarantee that vCPUs will see either the previous filter or the new
  3291. filter, e.g. MSRs with identical settings in both the old and new filter will
  3292. have deterministic behavior.
  3293. Similarly, if userspace wishes to intercept on denied accesses,
  3294. KVM_MSR_EXIT_REASON_FILTER must be enabled before activating any filters, and
  3295. left enabled until after all filters are deactivated. Failure to do so may
  3296. result in KVM injecting a #GP instead of exiting to userspace.
  3297. 4.98 KVM_CREATE_SPAPR_TCE_64
  3298. ----------------------------
  3299. :Capability: KVM_CAP_SPAPR_TCE_64
  3300. :Architectures: powerpc
  3301. :Type: vm ioctl
  3302. :Parameters: struct kvm_create_spapr_tce_64 (in)
  3303. :Returns: file descriptor for manipulating the created TCE table
  3304. This is an extension for KVM_CAP_SPAPR_TCE which only supports 32bit
  3305. windows, described in 4.62 KVM_CREATE_SPAPR_TCE
  3306. This capability uses extended struct in ioctl interface::
  3307. /* for KVM_CAP_SPAPR_TCE_64 */
  3308. struct kvm_create_spapr_tce_64 {
  3309. __u64 liobn;
  3310. __u32 page_shift;
  3311. __u32 flags;
  3312. __u64 offset; /* in pages */
  3313. __u64 size; /* in pages */
  3314. };
  3315. The aim of extension is to support an additional bigger DMA window with
  3316. a variable page size.
  3317. KVM_CREATE_SPAPR_TCE_64 receives a 64bit window size, an IOMMU page shift and
  3318. a bus offset of the corresponding DMA window, @size and @offset are numbers
  3319. of IOMMU pages.
  3320. @flags are not used at the moment.
  3321. The rest of functionality is identical to KVM_CREATE_SPAPR_TCE.
  3322. 4.99 KVM_REINJECT_CONTROL
  3323. -------------------------
  3324. :Capability: KVM_CAP_REINJECT_CONTROL
  3325. :Architectures: x86
  3326. :Type: vm ioctl
  3327. :Parameters: struct kvm_reinject_control (in)
  3328. :Returns: 0 on success,
  3329. -EFAULT if struct kvm_reinject_control cannot be read,
  3330. -ENXIO if KVM_CREATE_PIT or KVM_CREATE_PIT2 didn't succeed earlier.
  3331. i8254 (PIT) has two modes, reinject and !reinject. The default is reinject,
  3332. where KVM queues elapsed i8254 ticks and monitors completion of interrupt from
  3333. vector(s) that i8254 injects. Reinject mode dequeues a tick and injects its
  3334. interrupt whenever there isn't a pending interrupt from i8254.
  3335. !reinject mode injects an interrupt as soon as a tick arrives.
  3336. ::
  3337. struct kvm_reinject_control {
  3338. __u8 pit_reinject;
  3339. __u8 reserved[31];
  3340. };
  3341. pit_reinject = 0 (!reinject mode) is recommended, unless running an old
  3342. operating system that uses the PIT for timing (e.g. Linux 2.4.x).
  3343. 4.100 KVM_PPC_CONFIGURE_V3_MMU
  3344. ------------------------------
  3345. :Capability: KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3
  3346. :Architectures: ppc
  3347. :Type: vm ioctl
  3348. :Parameters: struct kvm_ppc_mmuv3_cfg (in)
  3349. :Returns: 0 on success,
  3350. -EFAULT if struct kvm_ppc_mmuv3_cfg cannot be read,
  3351. -EINVAL if the configuration is invalid
  3352. This ioctl controls whether the guest will use radix or HPT (hashed
  3353. page table) translation, and sets the pointer to the process table for
  3354. the guest.
  3355. ::
  3356. struct kvm_ppc_mmuv3_cfg {
  3357. __u64 flags;
  3358. __u64 process_table;
  3359. };
  3360. There are two bits that can be set in flags; KVM_PPC_MMUV3_RADIX and
  3361. KVM_PPC_MMUV3_GTSE. KVM_PPC_MMUV3_RADIX, if set, configures the guest
  3362. to use radix tree translation, and if clear, to use HPT translation.
  3363. KVM_PPC_MMUV3_GTSE, if set and if KVM permits it, configures the guest
  3364. to be able to use the global TLB and SLB invalidation instructions;
  3365. if clear, the guest may not use these instructions.
  3366. The process_table field specifies the address and size of the guest
  3367. process table, which is in the guest's space. This field is formatted
  3368. as the second doubleword of the partition table entry, as defined in
  3369. the Power ISA V3.00, Book III section 5.7.6.1.
  3370. 4.101 KVM_PPC_GET_RMMU_INFO
  3371. ---------------------------
  3372. :Capability: KVM_CAP_PPC_MMU_RADIX
  3373. :Architectures: ppc
  3374. :Type: vm ioctl
  3375. :Parameters: struct kvm_ppc_rmmu_info (out)
  3376. :Returns: 0 on success,
  3377. -EFAULT if struct kvm_ppc_rmmu_info cannot be written,
  3378. -EINVAL if no useful information can be returned
  3379. This ioctl returns a structure containing two things: (a) a list
  3380. containing supported radix tree geometries, and (b) a list that maps
  3381. page sizes to put in the "AP" (actual page size) field for the tlbie
  3382. (TLB invalidate entry) instruction.
  3383. ::
  3384. struct kvm_ppc_rmmu_info {
  3385. struct kvm_ppc_radix_geom {
  3386. __u8 page_shift;
  3387. __u8 level_bits[4];
  3388. __u8 pad[3];
  3389. } geometries[8];
  3390. __u32 ap_encodings[8];
  3391. };
  3392. The geometries[] field gives up to 8 supported geometries for the
  3393. radix page table, in terms of the log base 2 of the smallest page
  3394. size, and the number of bits indexed at each level of the tree, from
  3395. the PTE level up to the PGD level in that order. Any unused entries
  3396. will have 0 in the page_shift field.
  3397. The ap_encodings gives the supported page sizes and their AP field
  3398. encodings, encoded with the AP value in the top 3 bits and the log
  3399. base 2 of the page size in the bottom 6 bits.
  3400. 4.102 KVM_PPC_RESIZE_HPT_PREPARE
  3401. --------------------------------
  3402. :Capability: KVM_CAP_SPAPR_RESIZE_HPT
  3403. :Architectures: powerpc
  3404. :Type: vm ioctl
  3405. :Parameters: struct kvm_ppc_resize_hpt (in)
  3406. :Returns: 0 on successful completion,
  3407. >0 if a new HPT is being prepared, the value is an estimated
  3408. number of milliseconds until preparation is complete,
  3409. -EFAULT if struct kvm_reinject_control cannot be read,
  3410. -EINVAL if the supplied shift or flags are invalid,
  3411. -ENOMEM if unable to allocate the new HPT,
  3412. Used to implement the PAPR extension for runtime resizing of a guest's
  3413. Hashed Page Table (HPT). Specifically this starts, stops or monitors
  3414. the preparation of a new potential HPT for the guest, essentially
  3415. implementing the H_RESIZE_HPT_PREPARE hypercall.
  3416. ::
  3417. struct kvm_ppc_resize_hpt {
  3418. __u64 flags;
  3419. __u32 shift;
  3420. __u32 pad;
  3421. };
  3422. If called with shift > 0 when there is no pending HPT for the guest,
  3423. this begins preparation of a new pending HPT of size 2^(shift) bytes.
  3424. It then returns a positive integer with the estimated number of
  3425. milliseconds until preparation is complete.
  3426. If called when there is a pending HPT whose size does not match that
  3427. requested in the parameters, discards the existing pending HPT and
  3428. creates a new one as above.
  3429. If called when there is a pending HPT of the size requested, will:
  3430. * If preparation of the pending HPT is already complete, return 0
  3431. * If preparation of the pending HPT has failed, return an error
  3432. code, then discard the pending HPT.
  3433. * If preparation of the pending HPT is still in progress, return an
  3434. estimated number of milliseconds until preparation is complete.
  3435. If called with shift == 0, discards any currently pending HPT and
  3436. returns 0 (i.e. cancels any in-progress preparation).
  3437. flags is reserved for future expansion, currently setting any bits in
  3438. flags will result in an -EINVAL.
  3439. Normally this will be called repeatedly with the same parameters until
  3440. it returns <= 0. The first call will initiate preparation, subsequent
  3441. ones will monitor preparation until it completes or fails.
  3442. 4.103 KVM_PPC_RESIZE_HPT_COMMIT
  3443. -------------------------------
  3444. :Capability: KVM_CAP_SPAPR_RESIZE_HPT
  3445. :Architectures: powerpc
  3446. :Type: vm ioctl
  3447. :Parameters: struct kvm_ppc_resize_hpt (in)
  3448. :Returns: 0 on successful completion,
  3449. -EFAULT if struct kvm_reinject_control cannot be read,
  3450. -EINVAL if the supplied shift or flags are invalid,
  3451. -ENXIO is there is no pending HPT, or the pending HPT doesn't
  3452. have the requested size,
  3453. -EBUSY if the pending HPT is not fully prepared,
  3454. -ENOSPC if there was a hash collision when moving existing
  3455. HPT entries to the new HPT,
  3456. -EIO on other error conditions
  3457. Used to implement the PAPR extension for runtime resizing of a guest's
  3458. Hashed Page Table (HPT). Specifically this requests that the guest be
  3459. transferred to working with the new HPT, essentially implementing the
  3460. H_RESIZE_HPT_COMMIT hypercall.
  3461. ::
  3462. struct kvm_ppc_resize_hpt {
  3463. __u64 flags;
  3464. __u32 shift;
  3465. __u32 pad;
  3466. };
  3467. This should only be called after KVM_PPC_RESIZE_HPT_PREPARE has
  3468. returned 0 with the same parameters. In other cases
  3469. KVM_PPC_RESIZE_HPT_COMMIT will return an error (usually -ENXIO or
  3470. -EBUSY, though others may be possible if the preparation was started,
  3471. but failed).
  3472. This will have undefined effects on the guest if it has not already
  3473. placed itself in a quiescent state where no vcpu will make MMU enabled
  3474. memory accesses.
  3475. On successful completion, the pending HPT will become the guest's active
  3476. HPT and the previous HPT will be discarded.
  3477. On failure, the guest will still be operating on its previous HPT.
  3478. 4.104 KVM_X86_GET_MCE_CAP_SUPPORTED
  3479. -----------------------------------
  3480. :Capability: KVM_CAP_MCE
  3481. :Architectures: x86
  3482. :Type: system ioctl
  3483. :Parameters: u64 mce_cap (out)
  3484. :Returns: 0 on success, -1 on error
  3485. Returns supported MCE capabilities. The u64 mce_cap parameter
  3486. has the same format as the MSR_IA32_MCG_CAP register. Supported
  3487. capabilities will have the corresponding bits set.
  3488. 4.105 KVM_X86_SETUP_MCE
  3489. -----------------------
  3490. :Capability: KVM_CAP_MCE
  3491. :Architectures: x86
  3492. :Type: vcpu ioctl
  3493. :Parameters: u64 mcg_cap (in)
  3494. :Returns: 0 on success,
  3495. -EFAULT if u64 mcg_cap cannot be read,
  3496. -EINVAL if the requested number of banks is invalid,
  3497. -EINVAL if requested MCE capability is not supported.
  3498. Initializes MCE support for use. The u64 mcg_cap parameter
  3499. has the same format as the MSR_IA32_MCG_CAP register and
  3500. specifies which capabilities should be enabled. The maximum
  3501. supported number of error-reporting banks can be retrieved when
  3502. checking for KVM_CAP_MCE. The supported capabilities can be
  3503. retrieved with KVM_X86_GET_MCE_CAP_SUPPORTED.
  3504. 4.106 KVM_X86_SET_MCE
  3505. ---------------------
  3506. :Capability: KVM_CAP_MCE
  3507. :Architectures: x86
  3508. :Type: vcpu ioctl
  3509. :Parameters: struct kvm_x86_mce (in)
  3510. :Returns: 0 on success,
  3511. -EFAULT if struct kvm_x86_mce cannot be read,
  3512. -EINVAL if the bank number is invalid,
  3513. -EINVAL if VAL bit is not set in status field.
  3514. Inject a machine check error (MCE) into the guest. The input
  3515. parameter is::
  3516. struct kvm_x86_mce {
  3517. __u64 status;
  3518. __u64 addr;
  3519. __u64 misc;
  3520. __u64 mcg_status;
  3521. __u8 bank;
  3522. __u8 pad1[7];
  3523. __u64 pad2[3];
  3524. };
  3525. If the MCE being reported is an uncorrected error, KVM will
  3526. inject it as an MCE exception into the guest. If the guest
  3527. MCG_STATUS register reports that an MCE is in progress, KVM
  3528. causes an KVM_EXIT_SHUTDOWN vmexit.
  3529. Otherwise, if the MCE is a corrected error, KVM will just
  3530. store it in the corresponding bank (provided this bank is
  3531. not holding a previously reported uncorrected error).
  3532. 4.107 KVM_S390_GET_CMMA_BITS
  3533. ----------------------------
  3534. :Capability: KVM_CAP_S390_CMMA_MIGRATION
  3535. :Architectures: s390
  3536. :Type: vm ioctl
  3537. :Parameters: struct kvm_s390_cmma_log (in, out)
  3538. :Returns: 0 on success, a negative value on error
  3539. Errors:
  3540. ====== =============================================================
  3541. ENOMEM not enough memory can be allocated to complete the task
  3542. ENXIO if CMMA is not enabled
  3543. EINVAL if KVM_S390_CMMA_PEEK is not set but migration mode was not enabled
  3544. EINVAL if KVM_S390_CMMA_PEEK is not set but dirty tracking has been
  3545. disabled (and thus migration mode was automatically disabled)
  3546. EFAULT if the userspace address is invalid or if no page table is
  3547. present for the addresses (e.g. when using hugepages).
  3548. ====== =============================================================
  3549. This ioctl is used to get the values of the CMMA bits on the s390
  3550. architecture. It is meant to be used in two scenarios:
  3551. - During live migration to save the CMMA values. Live migration needs
  3552. to be enabled via the KVM_REQ_START_MIGRATION VM property.
  3553. - To non-destructively peek at the CMMA values, with the flag
  3554. KVM_S390_CMMA_PEEK set.
  3555. The ioctl takes parameters via the kvm_s390_cmma_log struct. The desired
  3556. values are written to a buffer whose location is indicated via the "values"
  3557. member in the kvm_s390_cmma_log struct. The values in the input struct are
  3558. also updated as needed.
  3559. Each CMMA value takes up one byte.
  3560. ::
  3561. struct kvm_s390_cmma_log {
  3562. __u64 start_gfn;
  3563. __u32 count;
  3564. __u32 flags;
  3565. union {
  3566. __u64 remaining;
  3567. __u64 mask;
  3568. };
  3569. __u64 values;
  3570. };
  3571. start_gfn is the number of the first guest frame whose CMMA values are
  3572. to be retrieved,
  3573. count is the length of the buffer in bytes,
  3574. values points to the buffer where the result will be written to.
  3575. If count is greater than KVM_S390_SKEYS_MAX, then it is considered to be
  3576. KVM_S390_SKEYS_MAX. KVM_S390_SKEYS_MAX is re-used for consistency with
  3577. other ioctls.
  3578. The result is written in the buffer pointed to by the field values, and
  3579. the values of the input parameter are updated as follows.
  3580. Depending on the flags, different actions are performed. The only
  3581. supported flag so far is KVM_S390_CMMA_PEEK.
  3582. The default behaviour if KVM_S390_CMMA_PEEK is not set is:
  3583. start_gfn will indicate the first page frame whose CMMA bits were dirty.
  3584. It is not necessarily the same as the one passed as input, as clean pages
  3585. are skipped.
  3586. count will indicate the number of bytes actually written in the buffer.
  3587. It can (and very often will) be smaller than the input value, since the
  3588. buffer is only filled until 16 bytes of clean values are found (which
  3589. are then not copied in the buffer). Since a CMMA migration block needs
  3590. the base address and the length, for a total of 16 bytes, we will send
  3591. back some clean data if there is some dirty data afterwards, as long as
  3592. the size of the clean data does not exceed the size of the header. This
  3593. allows to minimize the amount of data to be saved or transferred over
  3594. the network at the expense of more roundtrips to userspace. The next
  3595. invocation of the ioctl will skip over all the clean values, saving
  3596. potentially more than just the 16 bytes we found.
  3597. If KVM_S390_CMMA_PEEK is set:
  3598. the existing storage attributes are read even when not in migration
  3599. mode, and no other action is performed;
  3600. the output start_gfn will be equal to the input start_gfn,
  3601. the output count will be equal to the input count, except if the end of
  3602. memory has been reached.
  3603. In both cases:
  3604. the field "remaining" will indicate the total number of dirty CMMA values
  3605. still remaining, or 0 if KVM_S390_CMMA_PEEK is set and migration mode is
  3606. not enabled.
  3607. mask is unused.
  3608. values points to the userspace buffer where the result will be stored.
  3609. 4.108 KVM_S390_SET_CMMA_BITS
  3610. ----------------------------
  3611. :Capability: KVM_CAP_S390_CMMA_MIGRATION
  3612. :Architectures: s390
  3613. :Type: vm ioctl
  3614. :Parameters: struct kvm_s390_cmma_log (in)
  3615. :Returns: 0 on success, a negative value on error
  3616. This ioctl is used to set the values of the CMMA bits on the s390
  3617. architecture. It is meant to be used during live migration to restore
  3618. the CMMA values, but there are no restrictions on its use.
  3619. The ioctl takes parameters via the kvm_s390_cmma_values struct.
  3620. Each CMMA value takes up one byte.
  3621. ::
  3622. struct kvm_s390_cmma_log {
  3623. __u64 start_gfn;
  3624. __u32 count;
  3625. __u32 flags;
  3626. union {
  3627. __u64 remaining;
  3628. __u64 mask;
  3629. };
  3630. __u64 values;
  3631. };
  3632. start_gfn indicates the starting guest frame number,
  3633. count indicates how many values are to be considered in the buffer,
  3634. flags is not used and must be 0.
  3635. mask indicates which PGSTE bits are to be considered.
  3636. remaining is not used.
  3637. values points to the buffer in userspace where to store the values.
  3638. This ioctl can fail with -ENOMEM if not enough memory can be allocated to
  3639. complete the task, with -ENXIO if CMMA is not enabled, with -EINVAL if
  3640. the count field is too large (e.g. more than KVM_S390_CMMA_SIZE_MAX) or
  3641. if the flags field was not 0, with -EFAULT if the userspace address is
  3642. invalid, if invalid pages are written to (e.g. after the end of memory)
  3643. or if no page table is present for the addresses (e.g. when using
  3644. hugepages).
  3645. 4.109 KVM_PPC_GET_CPU_CHAR
  3646. --------------------------
  3647. :Capability: KVM_CAP_PPC_GET_CPU_CHAR
  3648. :Architectures: powerpc
  3649. :Type: vm ioctl
  3650. :Parameters: struct kvm_ppc_cpu_char (out)
  3651. :Returns: 0 on successful completion,
  3652. -EFAULT if struct kvm_ppc_cpu_char cannot be written
  3653. This ioctl gives userspace information about certain characteristics
  3654. of the CPU relating to speculative execution of instructions and
  3655. possible information leakage resulting from speculative execution (see
  3656. CVE-2017-5715, CVE-2017-5753 and CVE-2017-5754). The information is
  3657. returned in struct kvm_ppc_cpu_char, which looks like this::
  3658. struct kvm_ppc_cpu_char {
  3659. __u64 character; /* characteristics of the CPU */
  3660. __u64 behaviour; /* recommended software behaviour */
  3661. __u64 character_mask; /* valid bits in character */
  3662. __u64 behaviour_mask; /* valid bits in behaviour */
  3663. };
  3664. For extensibility, the character_mask and behaviour_mask fields
  3665. indicate which bits of character and behaviour have been filled in by
  3666. the kernel. If the set of defined bits is extended in future then
  3667. userspace will be able to tell whether it is running on a kernel that
  3668. knows about the new bits.
  3669. The character field describes attributes of the CPU which can help
  3670. with preventing inadvertent information disclosure - specifically,
  3671. whether there is an instruction to flash-invalidate the L1 data cache
  3672. (ori 30,30,0 or mtspr SPRN_TRIG2,rN), whether the L1 data cache is set
  3673. to a mode where entries can only be used by the thread that created
  3674. them, whether the bcctr[l] instruction prevents speculation, and
  3675. whether a speculation barrier instruction (ori 31,31,0) is provided.
  3676. The behaviour field describes actions that software should take to
  3677. prevent inadvertent information disclosure, and thus describes which
  3678. vulnerabilities the hardware is subject to; specifically whether the
  3679. L1 data cache should be flushed when returning to user mode from the
  3680. kernel, and whether a speculation barrier should be placed between an
  3681. array bounds check and the array access.
  3682. These fields use the same bit definitions as the new
  3683. H_GET_CPU_CHARACTERISTICS hypercall.
  3684. 4.110 KVM_MEMORY_ENCRYPT_OP
  3685. ---------------------------
  3686. :Capability: basic
  3687. :Architectures: x86
  3688. :Type: vm
  3689. :Parameters: an opaque platform specific structure (in/out)
  3690. :Returns: 0 on success; -1 on error
  3691. If the platform supports creating encrypted VMs then this ioctl can be used
  3692. for issuing platform-specific memory encryption commands to manage those
  3693. encrypted VMs.
  3694. Currently, this ioctl is used for issuing Secure Encrypted Virtualization
  3695. (SEV) commands on AMD Processors. The SEV commands are defined in
  3696. Documentation/virt/kvm/x86/amd-memory-encryption.rst.
  3697. 4.111 KVM_MEMORY_ENCRYPT_REG_REGION
  3698. -----------------------------------
  3699. :Capability: basic
  3700. :Architectures: x86
  3701. :Type: system
  3702. :Parameters: struct kvm_enc_region (in)
  3703. :Returns: 0 on success; -1 on error
  3704. This ioctl can be used to register a guest memory region which may
  3705. contain encrypted data (e.g. guest RAM, SMRAM etc).
  3706. It is used in the SEV-enabled guest. When encryption is enabled, a guest
  3707. memory region may contain encrypted data. The SEV memory encryption
  3708. engine uses a tweak such that two identical plaintext pages, each at
  3709. different locations will have differing ciphertexts. So swapping or
  3710. moving ciphertext of those pages will not result in plaintext being
  3711. swapped. So relocating (or migrating) physical backing pages for the SEV
  3712. guest will require some additional steps.
  3713. Note: The current SEV key management spec does not provide commands to
  3714. swap or migrate (move) ciphertext pages. Hence, for now we pin the guest
  3715. memory region registered with the ioctl.
  3716. 4.112 KVM_MEMORY_ENCRYPT_UNREG_REGION
  3717. -------------------------------------
  3718. :Capability: basic
  3719. :Architectures: x86
  3720. :Type: system
  3721. :Parameters: struct kvm_enc_region (in)
  3722. :Returns: 0 on success; -1 on error
  3723. This ioctl can be used to unregister the guest memory region registered
  3724. with KVM_MEMORY_ENCRYPT_REG_REGION ioctl above.
  3725. 4.113 KVM_HYPERV_EVENTFD
  3726. ------------------------
  3727. :Capability: KVM_CAP_HYPERV_EVENTFD
  3728. :Architectures: x86
  3729. :Type: vm ioctl
  3730. :Parameters: struct kvm_hyperv_eventfd (in)
  3731. This ioctl (un)registers an eventfd to receive notifications from the guest on
  3732. the specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without
  3733. causing a user exit. SIGNAL_EVENT hypercall with non-zero event flag number
  3734. (bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL user exit.
  3735. ::
  3736. struct kvm_hyperv_eventfd {
  3737. __u32 conn_id;
  3738. __s32 fd;
  3739. __u32 flags;
  3740. __u32 padding[3];
  3741. };
  3742. The conn_id field should fit within 24 bits::
  3743. #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
  3744. The acceptable values for the flags field are::
  3745. #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
  3746. :Returns: 0 on success,
  3747. -EINVAL if conn_id or flags is outside the allowed range,
  3748. -ENOENT on deassign if the conn_id isn't registered,
  3749. -EEXIST on assign if the conn_id is already registered
  3750. 4.114 KVM_GET_NESTED_STATE
  3751. --------------------------
  3752. :Capability: KVM_CAP_NESTED_STATE
  3753. :Architectures: x86
  3754. :Type: vcpu ioctl
  3755. :Parameters: struct kvm_nested_state (in/out)
  3756. :Returns: 0 on success, -1 on error
  3757. Errors:
  3758. ===== =============================================================
  3759. E2BIG the total state size exceeds the value of 'size' specified by
  3760. the user; the size required will be written into size.
  3761. ===== =============================================================
  3762. ::
  3763. struct kvm_nested_state {
  3764. __u16 flags;
  3765. __u16 format;
  3766. __u32 size;
  3767. union {
  3768. struct kvm_vmx_nested_state_hdr vmx;
  3769. struct kvm_svm_nested_state_hdr svm;
  3770. /* Pad the header to 128 bytes. */
  3771. __u8 pad[120];
  3772. } hdr;
  3773. union {
  3774. struct kvm_vmx_nested_state_data vmx[0];
  3775. struct kvm_svm_nested_state_data svm[0];
  3776. } data;
  3777. };
  3778. #define KVM_STATE_NESTED_GUEST_MODE 0x00000001
  3779. #define KVM_STATE_NESTED_RUN_PENDING 0x00000002
  3780. #define KVM_STATE_NESTED_EVMCS 0x00000004
  3781. #define KVM_STATE_NESTED_FORMAT_VMX 0
  3782. #define KVM_STATE_NESTED_FORMAT_SVM 1
  3783. #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000
  3784. #define KVM_STATE_NESTED_VMX_SMM_GUEST_MODE 0x00000001
  3785. #define KVM_STATE_NESTED_VMX_SMM_VMXON 0x00000002
  3786. #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001
  3787. struct kvm_vmx_nested_state_hdr {
  3788. __u64 vmxon_pa;
  3789. __u64 vmcs12_pa;
  3790. struct {
  3791. __u16 flags;
  3792. } smm;
  3793. __u32 flags;
  3794. __u64 preemption_timer_deadline;
  3795. };
  3796. struct kvm_vmx_nested_state_data {
  3797. __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
  3798. __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
  3799. };
  3800. This ioctl copies the vcpu's nested virtualization state from the kernel to
  3801. userspace.
  3802. The maximum size of the state can be retrieved by passing KVM_CAP_NESTED_STATE
  3803. to the KVM_CHECK_EXTENSION ioctl().
  3804. 4.115 KVM_SET_NESTED_STATE
  3805. --------------------------
  3806. :Capability: KVM_CAP_NESTED_STATE
  3807. :Architectures: x86
  3808. :Type: vcpu ioctl
  3809. :Parameters: struct kvm_nested_state (in)
  3810. :Returns: 0 on success, -1 on error
  3811. This copies the vcpu's kvm_nested_state struct from userspace to the kernel.
  3812. For the definition of struct kvm_nested_state, see KVM_GET_NESTED_STATE.
  3813. 4.116 KVM_(UN)REGISTER_COALESCED_MMIO
  3814. -------------------------------------
  3815. :Capability: KVM_CAP_COALESCED_MMIO (for coalesced mmio)
  3816. KVM_CAP_COALESCED_PIO (for coalesced pio)
  3817. :Architectures: all
  3818. :Type: vm ioctl
  3819. :Parameters: struct kvm_coalesced_mmio_zone
  3820. :Returns: 0 on success, < 0 on error
  3821. Coalesced I/O is a performance optimization that defers hardware
  3822. register write emulation so that userspace exits are avoided. It is
  3823. typically used to reduce the overhead of emulating frequently accessed
  3824. hardware registers.
  3825. When a hardware register is configured for coalesced I/O, write accesses
  3826. do not exit to userspace and their value is recorded in a ring buffer
  3827. that is shared between kernel and userspace.
  3828. Coalesced I/O is used if one or more write accesses to a hardware
  3829. register can be deferred until a read or a write to another hardware
  3830. register on the same device. This last access will cause a vmexit and
  3831. userspace will process accesses from the ring buffer before emulating
  3832. it. That will avoid exiting to userspace on repeated writes.
  3833. Coalesced pio is based on coalesced mmio. There is little difference
  3834. between coalesced mmio and pio except that coalesced pio records accesses
  3835. to I/O ports.
  3836. 4.117 KVM_CLEAR_DIRTY_LOG (vm ioctl)
  3837. ------------------------------------
  3838. :Capability: KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
  3839. :Architectures: x86, arm64, mips
  3840. :Type: vm ioctl
  3841. :Parameters: struct kvm_clear_dirty_log (in)
  3842. :Returns: 0 on success, -1 on error
  3843. ::
  3844. /* for KVM_CLEAR_DIRTY_LOG */
  3845. struct kvm_clear_dirty_log {
  3846. __u32 slot;
  3847. __u32 num_pages;
  3848. __u64 first_page;
  3849. union {
  3850. void __user *dirty_bitmap; /* one bit per page */
  3851. __u64 padding;
  3852. };
  3853. };
  3854. The ioctl clears the dirty status of pages in a memory slot, according to
  3855. the bitmap that is passed in struct kvm_clear_dirty_log's dirty_bitmap
  3856. field. Bit 0 of the bitmap corresponds to page "first_page" in the
  3857. memory slot, and num_pages is the size in bits of the input bitmap.
  3858. first_page must be a multiple of 64; num_pages must also be a multiple of
  3859. 64 unless first_page + num_pages is the size of the memory slot. For each
  3860. bit that is set in the input bitmap, the corresponding page is marked "clean"
  3861. in KVM's dirty bitmap, and dirty tracking is re-enabled for that page
  3862. (for example via write-protection, or by clearing the dirty bit in
  3863. a page table entry).
  3864. If KVM_CAP_MULTI_ADDRESS_SPACE is available, bits 16-31 of slot field specifies
  3865. the address space for which you want to clear the dirty status. See
  3866. KVM_SET_USER_MEMORY_REGION for details on the usage of slot field.
  3867. This ioctl is mostly useful when KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
  3868. is enabled; for more information, see the description of the capability.
  3869. However, it can always be used as long as KVM_CHECK_EXTENSION confirms
  3870. that KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is present.
  3871. 4.118 KVM_GET_SUPPORTED_HV_CPUID
  3872. --------------------------------
  3873. :Capability: KVM_CAP_HYPERV_CPUID (vcpu), KVM_CAP_SYS_HYPERV_CPUID (system)
  3874. :Architectures: x86
  3875. :Type: system ioctl, vcpu ioctl
  3876. :Parameters: struct kvm_cpuid2 (in/out)
  3877. :Returns: 0 on success, -1 on error
  3878. ::
  3879. struct kvm_cpuid2 {
  3880. __u32 nent;
  3881. __u32 padding;
  3882. struct kvm_cpuid_entry2 entries[0];
  3883. };
  3884. struct kvm_cpuid_entry2 {
  3885. __u32 function;
  3886. __u32 index;
  3887. __u32 flags;
  3888. __u32 eax;
  3889. __u32 ebx;
  3890. __u32 ecx;
  3891. __u32 edx;
  3892. __u32 padding[3];
  3893. };
  3894. This ioctl returns x86 cpuid features leaves related to Hyper-V emulation in
  3895. KVM. Userspace can use the information returned by this ioctl to construct
  3896. cpuid information presented to guests consuming Hyper-V enlightenments (e.g.
  3897. Windows or Hyper-V guests).
  3898. CPUID feature leaves returned by this ioctl are defined by Hyper-V Top Level
  3899. Functional Specification (TLFS). These leaves can't be obtained with
  3900. KVM_GET_SUPPORTED_CPUID ioctl because some of them intersect with KVM feature
  3901. leaves (0x40000000, 0x40000001).
  3902. Currently, the following list of CPUID leaves are returned:
  3903. - HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS
  3904. - HYPERV_CPUID_INTERFACE
  3905. - HYPERV_CPUID_VERSION
  3906. - HYPERV_CPUID_FEATURES
  3907. - HYPERV_CPUID_ENLIGHTMENT_INFO
  3908. - HYPERV_CPUID_IMPLEMENT_LIMITS
  3909. - HYPERV_CPUID_NESTED_FEATURES
  3910. - HYPERV_CPUID_SYNDBG_VENDOR_AND_MAX_FUNCTIONS
  3911. - HYPERV_CPUID_SYNDBG_INTERFACE
  3912. - HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES
  3913. Userspace invokes KVM_GET_SUPPORTED_HV_CPUID by passing a kvm_cpuid2 structure
  3914. with the 'nent' field indicating the number of entries in the variable-size
  3915. array 'entries'. If the number of entries is too low to describe all Hyper-V
  3916. feature leaves, an error (E2BIG) is returned. If the number is more or equal
  3917. to the number of Hyper-V feature leaves, the 'nent' field is adjusted to the
  3918. number of valid entries in the 'entries' array, which is then filled.
  3919. 'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved,
  3920. userspace should not expect to get any particular value there.
  3921. Note, vcpu version of KVM_GET_SUPPORTED_HV_CPUID is currently deprecated. Unlike
  3922. system ioctl which exposes all supported feature bits unconditionally, vcpu
  3923. version has the following quirks:
  3924. - HYPERV_CPUID_NESTED_FEATURES leaf and HV_X64_ENLIGHTENED_VMCS_RECOMMENDED
  3925. feature bit are only exposed when Enlightened VMCS was previously enabled
  3926. on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS).
  3927. - HV_STIMER_DIRECT_MODE_AVAILABLE bit is only exposed with in-kernel LAPIC.
  3928. (presumes KVM_CREATE_IRQCHIP has already been called).
  3929. 4.119 KVM_ARM_VCPU_FINALIZE
  3930. ---------------------------
  3931. :Architectures: arm64
  3932. :Type: vcpu ioctl
  3933. :Parameters: int feature (in)
  3934. :Returns: 0 on success, -1 on error
  3935. Errors:
  3936. ====== ==============================================================
  3937. EPERM feature not enabled, needs configuration, or already finalized
  3938. EINVAL feature unknown or not present
  3939. ====== ==============================================================
  3940. Recognised values for feature:
  3941. ===== ===========================================
  3942. arm64 KVM_ARM_VCPU_SVE (requires KVM_CAP_ARM_SVE)
  3943. ===== ===========================================
  3944. Finalizes the configuration of the specified vcpu feature.
  3945. The vcpu must already have been initialised, enabling the affected feature, by
  3946. means of a successful KVM_ARM_VCPU_INIT call with the appropriate flag set in
  3947. features[].
  3948. For affected vcpu features, this is a mandatory step that must be performed
  3949. before the vcpu is fully usable.
  3950. Between KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE, the feature may be
  3951. configured by use of ioctls such as KVM_SET_ONE_REG. The exact configuration
  3952. that should be performed and how to do it are feature-dependent.
  3953. Other calls that depend on a particular feature being finalized, such as
  3954. KVM_RUN, KVM_GET_REG_LIST, KVM_GET_ONE_REG and KVM_SET_ONE_REG, will fail with
  3955. -EPERM unless the feature has already been finalized by means of a
  3956. KVM_ARM_VCPU_FINALIZE call.
  3957. See KVM_ARM_VCPU_INIT for details of vcpu features that require finalization
  3958. using this ioctl.
  3959. 4.120 KVM_SET_PMU_EVENT_FILTER
  3960. ------------------------------
  3961. :Capability: KVM_CAP_PMU_EVENT_FILTER
  3962. :Architectures: x86
  3963. :Type: vm ioctl
  3964. :Parameters: struct kvm_pmu_event_filter (in)
  3965. :Returns: 0 on success, -1 on error
  3966. Errors:
  3967. ====== ============================================================
  3968. EFAULT args[0] cannot be accessed
  3969. EINVAL args[0] contains invalid data in the filter or filter events
  3970. E2BIG nevents is too large
  3971. EBUSY not enough memory to allocate the filter
  3972. ====== ============================================================
  3973. ::
  3974. struct kvm_pmu_event_filter {
  3975. __u32 action;
  3976. __u32 nevents;
  3977. __u32 fixed_counter_bitmap;
  3978. __u32 flags;
  3979. __u32 pad[4];
  3980. __u64 events[0];
  3981. };
  3982. This ioctl restricts the set of PMU events the guest can program by limiting
  3983. which event select and unit mask combinations are permitted.
  3984. The argument holds a list of filter events which will be allowed or denied.
  3985. Filter events only control general purpose counters; fixed purpose counters
  3986. are controlled by the fixed_counter_bitmap.
  3987. Valid values for 'flags'::
  3988. ``0``
  3989. To use this mode, clear the 'flags' field.
  3990. In this mode each event will contain an event select + unit mask.
  3991. When the guest attempts to program the PMU the guest's event select +
  3992. unit mask is compared against the filter events to determine whether the
  3993. guest should have access.
  3994. ``KVM_PMU_EVENT_FLAG_MASKED_EVENTS``
  3995. :Capability: KVM_CAP_PMU_EVENT_MASKED_EVENTS
  3996. In this mode each filter event will contain an event select, mask, match, and
  3997. exclude value. To encode a masked event use::
  3998. KVM_PMU_ENCODE_MASKED_ENTRY()
  3999. An encoded event will follow this layout::
  4000. Bits Description
  4001. ---- -----------
  4002. 7:0 event select (low bits)
  4003. 15:8 umask match
  4004. 31:16 unused
  4005. 35:32 event select (high bits)
  4006. 36:54 unused
  4007. 55 exclude bit
  4008. 63:56 umask mask
  4009. When the guest attempts to program the PMU, these steps are followed in
  4010. determining if the guest should have access:
  4011. 1. Match the event select from the guest against the filter events.
  4012. 2. If a match is found, match the guest's unit mask to the mask and match
  4013. values of the included filter events.
  4014. I.e. (unit mask & mask) == match && !exclude.
  4015. 3. If a match is found, match the guest's unit mask to the mask and match
  4016. values of the excluded filter events.
  4017. I.e. (unit mask & mask) == match && exclude.
  4018. 4.
  4019. a. If an included match is found and an excluded match is not found, filter
  4020. the event.
  4021. b. For everything else, do not filter the event.
  4022. 5.
  4023. a. If the event is filtered and it's an allow list, allow the guest to
  4024. program the event.
  4025. b. If the event is filtered and it's a deny list, do not allow the guest to
  4026. program the event.
  4027. When setting a new pmu event filter, -EINVAL will be returned if any of the
  4028. unused fields are set or if any of the high bits (35:32) in the event
  4029. select are set when called on Intel.
  4030. Valid values for 'action'::
  4031. #define KVM_PMU_EVENT_ALLOW 0
  4032. #define KVM_PMU_EVENT_DENY 1
  4033. Via this API, KVM userspace can also control the behavior of the VM's fixed
  4034. counters (if any) by configuring the "action" and "fixed_counter_bitmap" fields.
  4035. Specifically, KVM follows the following pseudo-code when determining whether to
  4036. allow the guest FixCtr[i] to count its pre-defined fixed event::
  4037. FixCtr[i]_is_allowed = (action == ALLOW) && (bitmap & BIT(i)) ||
  4038. (action == DENY) && !(bitmap & BIT(i));
  4039. FixCtr[i]_is_denied = !FixCtr[i]_is_allowed;
  4040. KVM always consumes fixed_counter_bitmap, it's userspace's responsibility to
  4041. ensure fixed_counter_bitmap is set correctly, e.g. if userspace wants to define
  4042. a filter that only affects general purpose counters.
  4043. Note, the "events" field also applies to fixed counters' hardcoded event_select
  4044. and unit_mask values. "fixed_counter_bitmap" has higher priority than "events"
  4045. if there is a contradiction between the two.
  4046. 4.121 KVM_PPC_SVM_OFF
  4047. ---------------------
  4048. :Capability: basic
  4049. :Architectures: powerpc
  4050. :Type: vm ioctl
  4051. :Parameters: none
  4052. :Returns: 0 on successful completion,
  4053. Errors:
  4054. ====== ================================================================
  4055. EINVAL if ultravisor failed to terminate the secure guest
  4056. ENOMEM if hypervisor failed to allocate new radix page tables for guest
  4057. ====== ================================================================
  4058. This ioctl is used to turn off the secure mode of the guest or transition
  4059. the guest from secure mode to normal mode. This is invoked when the guest
  4060. is reset. This has no effect if called for a normal guest.
  4061. This ioctl issues an ultravisor call to terminate the secure guest,
  4062. unpins the VPA pages and releases all the device pages that are used to
  4063. track the secure pages by hypervisor.
  4064. 4.122 KVM_S390_NORMAL_RESET
  4065. ---------------------------
  4066. :Capability: KVM_CAP_S390_VCPU_RESETS
  4067. :Architectures: s390
  4068. :Type: vcpu ioctl
  4069. :Parameters: none
  4070. :Returns: 0
  4071. This ioctl resets VCPU registers and control structures according to
  4072. the cpu reset definition in the POP (Principles Of Operation).
  4073. 4.123 KVM_S390_INITIAL_RESET
  4074. ----------------------------
  4075. :Capability: none
  4076. :Architectures: s390
  4077. :Type: vcpu ioctl
  4078. :Parameters: none
  4079. :Returns: 0
  4080. This ioctl resets VCPU registers and control structures according to
  4081. the initial cpu reset definition in the POP. However, the cpu is not
  4082. put into ESA mode. This reset is a superset of the normal reset.
  4083. 4.124 KVM_S390_CLEAR_RESET
  4084. --------------------------
  4085. :Capability: KVM_CAP_S390_VCPU_RESETS
  4086. :Architectures: s390
  4087. :Type: vcpu ioctl
  4088. :Parameters: none
  4089. :Returns: 0
  4090. This ioctl resets VCPU registers and control structures according to
  4091. the clear cpu reset definition in the POP. However, the cpu is not put
  4092. into ESA mode. This reset is a superset of the initial reset.
  4093. 4.125 KVM_S390_PV_COMMAND
  4094. -------------------------
  4095. :Capability: KVM_CAP_S390_PROTECTED
  4096. :Architectures: s390
  4097. :Type: vm ioctl
  4098. :Parameters: struct kvm_pv_cmd
  4099. :Returns: 0 on success, < 0 on error
  4100. ::
  4101. struct kvm_pv_cmd {
  4102. __u32 cmd; /* Command to be executed */
  4103. __u16 rc; /* Ultravisor return code */
  4104. __u16 rrc; /* Ultravisor return reason code */
  4105. __u64 data; /* Data or address */
  4106. __u32 flags; /* flags for future extensions. Must be 0 for now */
  4107. __u32 reserved[3];
  4108. };
  4109. **Ultravisor return codes**
  4110. The Ultravisor return (reason) codes are provided by the kernel if a
  4111. Ultravisor call has been executed to achieve the results expected by
  4112. the command. Therefore they are independent of the IOCTL return
  4113. code. If KVM changes `rc`, its value will always be greater than 0
  4114. hence setting it to 0 before issuing a PV command is advised to be
  4115. able to detect a change of `rc`.
  4116. **cmd values:**
  4117. KVM_PV_ENABLE
  4118. Allocate memory and register the VM with the Ultravisor, thereby
  4119. donating memory to the Ultravisor that will become inaccessible to
  4120. KVM. All existing CPUs are converted to protected ones. After this
  4121. command has succeeded, any CPU added via hotplug will become
  4122. protected during its creation as well.
  4123. Errors:
  4124. ===== =============================
  4125. EINTR an unmasked signal is pending
  4126. ===== =============================
  4127. KVM_PV_DISABLE
  4128. Deregister the VM from the Ultravisor and reclaim the memory that had
  4129. been donated to the Ultravisor, making it usable by the kernel again.
  4130. All registered VCPUs are converted back to non-protected ones. If a
  4131. previous protected VM had been prepared for asynchronous teardown with
  4132. KVM_PV_ASYNC_CLEANUP_PREPARE and not subsequently torn down with
  4133. KVM_PV_ASYNC_CLEANUP_PERFORM, it will be torn down in this call
  4134. together with the current protected VM.
  4135. KVM_PV_VM_SET_SEC_PARMS
  4136. Pass the image header from VM memory to the Ultravisor in
  4137. preparation of image unpacking and verification.
  4138. KVM_PV_VM_UNPACK
  4139. Unpack (protect and decrypt) a page of the encrypted boot image.
  4140. KVM_PV_VM_VERIFY
  4141. Verify the integrity of the unpacked image. Only if this succeeds,
  4142. KVM is allowed to start protected VCPUs.
  4143. KVM_PV_INFO
  4144. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  4145. Presents an API that provides Ultravisor related data to userspace
  4146. via subcommands. len_max is the size of the user space buffer,
  4147. len_written is KVM's indication of how much bytes of that buffer
  4148. were actually written to. len_written can be used to determine the
  4149. valid fields if more response fields are added in the future.
  4150. ::
  4151. enum pv_cmd_info_id {
  4152. KVM_PV_INFO_VM,
  4153. KVM_PV_INFO_DUMP,
  4154. };
  4155. struct kvm_s390_pv_info_header {
  4156. __u32 id;
  4157. __u32 len_max;
  4158. __u32 len_written;
  4159. __u32 reserved;
  4160. };
  4161. struct kvm_s390_pv_info {
  4162. struct kvm_s390_pv_info_header header;
  4163. struct kvm_s390_pv_info_dump dump;
  4164. struct kvm_s390_pv_info_vm vm;
  4165. };
  4166. **subcommands:**
  4167. KVM_PV_INFO_VM
  4168. This subcommand provides basic Ultravisor information for PV
  4169. hosts. These values are likely also exported as files in the sysfs
  4170. firmware UV query interface but they are more easily available to
  4171. programs in this API.
  4172. The installed calls and feature_indication members provide the
  4173. installed UV calls and the UV's other feature indications.
  4174. The max_* members provide information about the maximum number of PV
  4175. vcpus, PV guests and PV guest memory size.
  4176. ::
  4177. struct kvm_s390_pv_info_vm {
  4178. __u64 inst_calls_list[4];
  4179. __u64 max_cpus;
  4180. __u64 max_guests;
  4181. __u64 max_guest_addr;
  4182. __u64 feature_indication;
  4183. };
  4184. KVM_PV_INFO_DUMP
  4185. This subcommand provides information related to dumping PV guests.
  4186. ::
  4187. struct kvm_s390_pv_info_dump {
  4188. __u64 dump_cpu_buffer_len;
  4189. __u64 dump_config_mem_buffer_per_1m;
  4190. __u64 dump_config_finalize_len;
  4191. };
  4192. KVM_PV_DUMP
  4193. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  4194. Presents an API that provides calls which facilitate dumping a
  4195. protected VM.
  4196. ::
  4197. struct kvm_s390_pv_dmp {
  4198. __u64 subcmd;
  4199. __u64 buff_addr;
  4200. __u64 buff_len;
  4201. __u64 gaddr; /* For dump storage state */
  4202. };
  4203. **subcommands:**
  4204. KVM_PV_DUMP_INIT
  4205. Initializes the dump process of a protected VM. If this call does
  4206. not succeed all other subcommands will fail with -EINVAL. This
  4207. subcommand will return -EINVAL if a dump process has not yet been
  4208. completed.
  4209. Not all PV vms can be dumped, the owner needs to set `dump
  4210. allowed` PCF bit 34 in the SE header to allow dumping.
  4211. KVM_PV_DUMP_CONFIG_STOR_STATE
  4212. Stores `buff_len` bytes of tweak component values starting with
  4213. the 1MB block specified by the absolute guest address
  4214. (`gaddr`). `buff_len` needs to be `conf_dump_storage_state_len`
  4215. aligned and at least >= the `conf_dump_storage_state_len` value
  4216. provided by the dump uv_info data. buff_user might be written to
  4217. even if an error rc is returned. For instance if we encounter a
  4218. fault after writing the first page of data.
  4219. KVM_PV_DUMP_COMPLETE
  4220. If the subcommand succeeds it completes the dump process and lets
  4221. KVM_PV_DUMP_INIT be called again.
  4222. On success `conf_dump_finalize_len` bytes of completion data will be
  4223. stored to the `buff_addr`. The completion data contains a key
  4224. derivation seed, IV, tweak nonce and encryption keys as well as an
  4225. authentication tag all of which are needed to decrypt the dump at a
  4226. later time.
  4227. KVM_PV_ASYNC_CLEANUP_PREPARE
  4228. :Capability: KVM_CAP_S390_PROTECTED_ASYNC_DISABLE
  4229. Prepare the current protected VM for asynchronous teardown. Most
  4230. resources used by the current protected VM will be set aside for a
  4231. subsequent asynchronous teardown. The current protected VM will then
  4232. resume execution immediately as non-protected. There can be at most
  4233. one protected VM prepared for asynchronous teardown at any time. If
  4234. a protected VM had already been prepared for teardown without
  4235. subsequently calling KVM_PV_ASYNC_CLEANUP_PERFORM, this call will
  4236. fail. In that case, the userspace process should issue a normal
  4237. KVM_PV_DISABLE. The resources set aside with this call will need to
  4238. be cleaned up with a subsequent call to KVM_PV_ASYNC_CLEANUP_PERFORM
  4239. or KVM_PV_DISABLE, otherwise they will be cleaned up when KVM
  4240. terminates. KVM_PV_ASYNC_CLEANUP_PREPARE can be called again as soon
  4241. as cleanup starts, i.e. before KVM_PV_ASYNC_CLEANUP_PERFORM finishes.
  4242. KVM_PV_ASYNC_CLEANUP_PERFORM
  4243. :Capability: KVM_CAP_S390_PROTECTED_ASYNC_DISABLE
  4244. Tear down the protected VM previously prepared for teardown with
  4245. KVM_PV_ASYNC_CLEANUP_PREPARE. The resources that had been set aside
  4246. will be freed during the execution of this command. This PV command
  4247. should ideally be issued by userspace from a separate thread. If a
  4248. fatal signal is received (or the process terminates naturally), the
  4249. command will terminate immediately without completing, and the normal
  4250. KVM shutdown procedure will take care of cleaning up all remaining
  4251. protected VMs, including the ones whose teardown was interrupted by
  4252. process termination.
  4253. 4.126 KVM_XEN_HVM_SET_ATTR
  4254. --------------------------
  4255. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4256. :Architectures: x86
  4257. :Type: vm ioctl
  4258. :Parameters: struct kvm_xen_hvm_attr
  4259. :Returns: 0 on success, < 0 on error
  4260. ::
  4261. struct kvm_xen_hvm_attr {
  4262. __u16 type;
  4263. __u16 pad[3];
  4264. union {
  4265. __u8 long_mode;
  4266. __u8 vector;
  4267. __u8 runstate_update_flag;
  4268. union {
  4269. __u64 gfn;
  4270. __u64 hva;
  4271. } shared_info;
  4272. struct {
  4273. __u32 send_port;
  4274. __u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */
  4275. __u32 flags;
  4276. union {
  4277. struct {
  4278. __u32 port;
  4279. __u32 vcpu;
  4280. __u32 priority;
  4281. } port;
  4282. struct {
  4283. __u32 port; /* Zero for eventfd */
  4284. __s32 fd;
  4285. } eventfd;
  4286. __u32 padding[4];
  4287. } deliver;
  4288. } evtchn;
  4289. __u32 xen_version;
  4290. __u64 pad[8];
  4291. } u;
  4292. };
  4293. type values:
  4294. KVM_XEN_ATTR_TYPE_LONG_MODE
  4295. Sets the ABI mode of the VM to 32-bit or 64-bit (long mode). This
  4296. determines the layout of the shared_info page exposed to the VM.
  4297. KVM_XEN_ATTR_TYPE_SHARED_INFO
  4298. Sets the guest physical frame number at which the Xen shared_info
  4299. page resides. Note that although Xen places vcpu_info for the first
  4300. 32 vCPUs in the shared_info page, KVM does not automatically do so
  4301. and instead requires that KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO or
  4302. KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA be used explicitly even when
  4303. the vcpu_info for a given vCPU resides at the "default" location
  4304. in the shared_info page. This is because KVM may not be aware of
  4305. the Xen CPU id which is used as the index into the vcpu_info[]
  4306. array, so may know the correct default location.
  4307. Note that the shared_info page may be constantly written to by KVM;
  4308. it contains the event channel bitmap used to deliver interrupts to
  4309. a Xen guest, amongst other things. It is exempt from dirty tracking
  4310. mechanisms — KVM will not explicitly mark the page as dirty each
  4311. time an event channel interrupt is delivered to the guest! Thus,
  4312. userspace should always assume that the designated GFN is dirty if
  4313. any vCPU has been running or any event channel interrupts can be
  4314. routed to the guest.
  4315. Setting the gfn to KVM_XEN_INVALID_GFN will disable the shared_info
  4316. page.
  4317. KVM_XEN_ATTR_TYPE_SHARED_INFO_HVA
  4318. If the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA flag is also set in the
  4319. Xen capabilities, then this attribute may be used to set the
  4320. userspace address at which the shared_info page resides, which
  4321. will always be fixed in the VMM regardless of where it is mapped
  4322. in guest physical address space. This attribute should be used in
  4323. preference to KVM_XEN_ATTR_TYPE_SHARED_INFO as it avoids
  4324. unnecessary invalidation of an internal cache when the page is
  4325. re-mapped in guest physcial address space.
  4326. Setting the hva to zero will disable the shared_info page.
  4327. KVM_XEN_ATTR_TYPE_UPCALL_VECTOR
  4328. Sets the exception vector used to deliver Xen event channel upcalls.
  4329. This is the HVM-wide vector injected directly by the hypervisor
  4330. (not through the local APIC), typically configured by a guest via
  4331. HVM_PARAM_CALLBACK_IRQ. This can be disabled again (e.g. for guest
  4332. SHUTDOWN_soft_reset) by setting it to zero.
  4333. KVM_XEN_ATTR_TYPE_EVTCHN
  4334. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4335. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures
  4336. an outbound port number for interception of EVTCHNOP_send requests
  4337. from the guest. A given sending port number may be directed back to
  4338. a specified vCPU (by APIC ID) / port / priority on the guest, or to
  4339. trigger events on an eventfd. The vCPU and priority can be changed
  4340. by setting KVM_XEN_EVTCHN_UPDATE in a subsequent call, but other
  4341. fields cannot change for a given sending port. A port mapping is
  4342. removed by using KVM_XEN_EVTCHN_DEASSIGN in the flags field. Passing
  4343. KVM_XEN_EVTCHN_RESET in the flags field removes all interception of
  4344. outbound event channels. The values of the flags field are mutually
  4345. exclusive and cannot be combined as a bitmask.
  4346. KVM_XEN_ATTR_TYPE_XEN_VERSION
  4347. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4348. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It configures
  4349. the 32-bit version code returned to the guest when it invokes the
  4350. XENVER_version call; typically (XEN_MAJOR << 16 | XEN_MINOR). PV
  4351. Xen guests will often use this to as a dummy hypercall to trigger
  4352. event channel delivery, so responding within the kernel without
  4353. exiting to userspace is beneficial.
  4354. KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG
  4355. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4356. support for KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG. It enables the
  4357. XEN_RUNSTATE_UPDATE flag which allows guest vCPUs to safely read
  4358. other vCPUs' vcpu_runstate_info. Xen guests enable this feature via
  4359. the VMASST_TYPE_runstate_update_flag of the HYPERVISOR_vm_assist
  4360. hypercall.
  4361. 4.127 KVM_XEN_HVM_GET_ATTR
  4362. --------------------------
  4363. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4364. :Architectures: x86
  4365. :Type: vm ioctl
  4366. :Parameters: struct kvm_xen_hvm_attr
  4367. :Returns: 0 on success, < 0 on error
  4368. Allows Xen VM attributes to be read. For the structure and types,
  4369. see KVM_XEN_HVM_SET_ATTR above. The KVM_XEN_ATTR_TYPE_EVTCHN
  4370. attribute cannot be read.
  4371. 4.128 KVM_XEN_VCPU_SET_ATTR
  4372. ---------------------------
  4373. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4374. :Architectures: x86
  4375. :Type: vcpu ioctl
  4376. :Parameters: struct kvm_xen_vcpu_attr
  4377. :Returns: 0 on success, < 0 on error
  4378. ::
  4379. struct kvm_xen_vcpu_attr {
  4380. __u16 type;
  4381. __u16 pad[3];
  4382. union {
  4383. __u64 gpa;
  4384. __u64 pad[4];
  4385. struct {
  4386. __u64 state;
  4387. __u64 state_entry_time;
  4388. __u64 time_running;
  4389. __u64 time_runnable;
  4390. __u64 time_blocked;
  4391. __u64 time_offline;
  4392. } runstate;
  4393. __u32 vcpu_id;
  4394. struct {
  4395. __u32 port;
  4396. __u32 priority;
  4397. __u64 expires_ns;
  4398. } timer;
  4399. __u8 vector;
  4400. } u;
  4401. };
  4402. type values:
  4403. KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO
  4404. Sets the guest physical address of the vcpu_info for a given vCPU.
  4405. As with the shared_info page for the VM, the corresponding page may be
  4406. dirtied at any time if event channel interrupt delivery is enabled, so
  4407. userspace should always assume that the page is dirty without relying
  4408. on dirty logging. Setting the gpa to KVM_XEN_INVALID_GPA will disable
  4409. the vcpu_info.
  4410. KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA
  4411. If the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA flag is also set in the
  4412. Xen capabilities, then this attribute may be used to set the
  4413. userspace address of the vcpu_info for a given vCPU. It should
  4414. only be used when the vcpu_info resides at the "default" location
  4415. in the shared_info page. In this case it is safe to assume the
  4416. userspace address will not change, because the shared_info page is
  4417. an overlay on guest memory and remains at a fixed host address
  4418. regardless of where it is mapped in guest physical address space
  4419. and hence unnecessary invalidation of an internal cache may be
  4420. avoided if the guest memory layout is modified.
  4421. If the vcpu_info does not reside at the "default" location then
  4422. it is not guaranteed to remain at the same host address and
  4423. hence the aforementioned cache invalidation is required.
  4424. KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO
  4425. Sets the guest physical address of an additional pvclock structure
  4426. for a given vCPU. This is typically used for guest vsyscall support.
  4427. Setting the gpa to KVM_XEN_INVALID_GPA will disable the structure.
  4428. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR
  4429. Sets the guest physical address of the vcpu_runstate_info for a given
  4430. vCPU. This is how a Xen guest tracks CPU state such as steal time.
  4431. Setting the gpa to KVM_XEN_INVALID_GPA will disable the runstate area.
  4432. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT
  4433. Sets the runstate (RUNSTATE_running/_runnable/_blocked/_offline) of
  4434. the given vCPU from the .u.runstate.state member of the structure.
  4435. KVM automatically accounts running and runnable time but blocked
  4436. and offline states are only entered explicitly.
  4437. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA
  4438. Sets all fields of the vCPU runstate data from the .u.runstate member
  4439. of the structure, including the current runstate. The state_entry_time
  4440. must equal the sum of the other four times.
  4441. KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST
  4442. This *adds* the contents of the .u.runstate members of the structure
  4443. to the corresponding members of the given vCPU's runstate data, thus
  4444. permitting atomic adjustments to the runstate times. The adjustment
  4445. to the state_entry_time must equal the sum of the adjustments to the
  4446. other four times. The state field must be set to -1, or to a valid
  4447. runstate value (RUNSTATE_running, RUNSTATE_runnable, RUNSTATE_blocked
  4448. or RUNSTATE_offline) to set the current accounted state as of the
  4449. adjusted state_entry_time.
  4450. KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID
  4451. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4452. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the Xen
  4453. vCPU ID of the given vCPU, to allow timer-related VCPU operations to
  4454. be intercepted by KVM.
  4455. KVM_XEN_VCPU_ATTR_TYPE_TIMER
  4456. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4457. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the
  4458. event channel port/priority for the VIRQ_TIMER of the vCPU, as well
  4459. as allowing a pending timer to be saved/restored. Setting the timer
  4460. port to zero disables kernel handling of the singleshot timer.
  4461. KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR
  4462. This attribute is available when the KVM_CAP_XEN_HVM ioctl indicates
  4463. support for KVM_XEN_HVM_CONFIG_EVTCHN_SEND features. It sets the
  4464. per-vCPU local APIC upcall vector, configured by a Xen guest with
  4465. the HVMOP_set_evtchn_upcall_vector hypercall. This is typically
  4466. used by Windows guests, and is distinct from the HVM-wide upcall
  4467. vector configured with HVM_PARAM_CALLBACK_IRQ. It is disabled by
  4468. setting the vector to zero.
  4469. 4.129 KVM_XEN_VCPU_GET_ATTR
  4470. ---------------------------
  4471. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO
  4472. :Architectures: x86
  4473. :Type: vcpu ioctl
  4474. :Parameters: struct kvm_xen_vcpu_attr
  4475. :Returns: 0 on success, < 0 on error
  4476. Allows Xen vCPU attributes to be read. For the structure and types,
  4477. see KVM_XEN_VCPU_SET_ATTR above.
  4478. The KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST type may not be used
  4479. with the KVM_XEN_VCPU_GET_ATTR ioctl.
  4480. 4.130 KVM_ARM_MTE_COPY_TAGS
  4481. ---------------------------
  4482. :Capability: KVM_CAP_ARM_MTE
  4483. :Architectures: arm64
  4484. :Type: vm ioctl
  4485. :Parameters: struct kvm_arm_copy_mte_tags
  4486. :Returns: number of bytes copied, < 0 on error (-EINVAL for incorrect
  4487. arguments, -EFAULT if memory cannot be accessed).
  4488. ::
  4489. struct kvm_arm_copy_mte_tags {
  4490. __u64 guest_ipa;
  4491. __u64 length;
  4492. void __user *addr;
  4493. __u64 flags;
  4494. __u64 reserved[2];
  4495. };
  4496. Copies Memory Tagging Extension (MTE) tags to/from guest tag memory. The
  4497. ``guest_ipa`` and ``length`` fields must be ``PAGE_SIZE`` aligned.
  4498. ``length`` must not be bigger than 2^31 - PAGE_SIZE bytes. The ``addr``
  4499. field must point to a buffer which the tags will be copied to or from.
  4500. ``flags`` specifies the direction of copy, either ``KVM_ARM_TAGS_TO_GUEST`` or
  4501. ``KVM_ARM_TAGS_FROM_GUEST``.
  4502. The size of the buffer to store the tags is ``(length / 16)`` bytes
  4503. (granules in MTE are 16 bytes long). Each byte contains a single tag
  4504. value. This matches the format of ``PTRACE_PEEKMTETAGS`` and
  4505. ``PTRACE_POKEMTETAGS``.
  4506. If an error occurs before any data is copied then a negative error code is
  4507. returned. If some tags have been copied before an error occurs then the number
  4508. of bytes successfully copied is returned. If the call completes successfully
  4509. then ``length`` is returned.
  4510. 4.131 KVM_GET_SREGS2
  4511. --------------------
  4512. :Capability: KVM_CAP_SREGS2
  4513. :Architectures: x86
  4514. :Type: vcpu ioctl
  4515. :Parameters: struct kvm_sregs2 (out)
  4516. :Returns: 0 on success, -1 on error
  4517. Reads special registers from the vcpu.
  4518. This ioctl (when supported) replaces the KVM_GET_SREGS.
  4519. ::
  4520. struct kvm_sregs2 {
  4521. /* out (KVM_GET_SREGS2) / in (KVM_SET_SREGS2) */
  4522. struct kvm_segment cs, ds, es, fs, gs, ss;
  4523. struct kvm_segment tr, ldt;
  4524. struct kvm_dtable gdt, idt;
  4525. __u64 cr0, cr2, cr3, cr4, cr8;
  4526. __u64 efer;
  4527. __u64 apic_base;
  4528. __u64 flags;
  4529. __u64 pdptrs[4];
  4530. };
  4531. flags values for ``kvm_sregs2``:
  4532. ``KVM_SREGS2_FLAGS_PDPTRS_VALID``
  4533. Indicates that the struct contains valid PDPTR values.
  4534. 4.132 KVM_SET_SREGS2
  4535. --------------------
  4536. :Capability: KVM_CAP_SREGS2
  4537. :Architectures: x86
  4538. :Type: vcpu ioctl
  4539. :Parameters: struct kvm_sregs2 (in)
  4540. :Returns: 0 on success, -1 on error
  4541. Writes special registers into the vcpu.
  4542. See KVM_GET_SREGS2 for the data structures.
  4543. This ioctl (when supported) replaces the KVM_SET_SREGS.
  4544. 4.133 KVM_GET_STATS_FD
  4545. ----------------------
  4546. :Capability: KVM_CAP_STATS_BINARY_FD
  4547. :Architectures: all
  4548. :Type: vm ioctl, vcpu ioctl
  4549. :Parameters: none
  4550. :Returns: statistics file descriptor on success, < 0 on error
  4551. Errors:
  4552. ====== ======================================================
  4553. ENOMEM if the fd could not be created due to lack of memory
  4554. EMFILE if the number of opened files exceeds the limit
  4555. ====== ======================================================
  4556. The returned file descriptor can be used to read VM/vCPU statistics data in
  4557. binary format. The data in the file descriptor consists of four blocks
  4558. organized as follows:
  4559. +-------------+
  4560. | Header |
  4561. +-------------+
  4562. | id string |
  4563. +-------------+
  4564. | Descriptors |
  4565. +-------------+
  4566. | Stats Data |
  4567. +-------------+
  4568. Apart from the header starting at offset 0, please be aware that it is
  4569. not guaranteed that the four blocks are adjacent or in the above order;
  4570. the offsets of the id, descriptors and data blocks are found in the
  4571. header. However, all four blocks are aligned to 64 bit offsets in the
  4572. file and they do not overlap.
  4573. All blocks except the data block are immutable. Userspace can read them
  4574. only one time after retrieving the file descriptor, and then use ``pread`` or
  4575. ``lseek`` to read the statistics repeatedly.
  4576. All data is in system endianness.
  4577. The format of the header is as follows::
  4578. struct kvm_stats_header {
  4579. __u32 flags;
  4580. __u32 name_size;
  4581. __u32 num_desc;
  4582. __u32 id_offset;
  4583. __u32 desc_offset;
  4584. __u32 data_offset;
  4585. };
  4586. The ``flags`` field is not used at the moment. It is always read as 0.
  4587. The ``name_size`` field is the size (in byte) of the statistics name string
  4588. (including trailing '\0') which is contained in the "id string" block and
  4589. appended at the end of every descriptor.
  4590. The ``num_desc`` field is the number of descriptors that are included in the
  4591. descriptor block. (The actual number of values in the data block may be
  4592. larger, since each descriptor may comprise more than one value).
  4593. The ``id_offset`` field is the offset of the id string from the start of the
  4594. file indicated by the file descriptor. It is a multiple of 8.
  4595. The ``desc_offset`` field is the offset of the Descriptors block from the start
  4596. of the file indicated by the file descriptor. It is a multiple of 8.
  4597. The ``data_offset`` field is the offset of the Stats Data block from the start
  4598. of the file indicated by the file descriptor. It is a multiple of 8.
  4599. The id string block contains a string which identifies the file descriptor on
  4600. which KVM_GET_STATS_FD was invoked. The size of the block, including the
  4601. trailing ``'\0'``, is indicated by the ``name_size`` field in the header.
  4602. The descriptors block is only needed to be read once for the lifetime of the
  4603. file descriptor contains a sequence of ``struct kvm_stats_desc``, each followed
  4604. by a string of size ``name_size``.
  4605. ::
  4606. #define KVM_STATS_TYPE_SHIFT 0
  4607. #define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT)
  4608. #define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT)
  4609. #define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT)
  4610. #define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT)
  4611. #define KVM_STATS_TYPE_LINEAR_HIST (0x3 << KVM_STATS_TYPE_SHIFT)
  4612. #define KVM_STATS_TYPE_LOG_HIST (0x4 << KVM_STATS_TYPE_SHIFT)
  4613. #define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_LOG_HIST
  4614. #define KVM_STATS_UNIT_SHIFT 4
  4615. #define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT)
  4616. #define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT)
  4617. #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)
  4618. #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
  4619. #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
  4620. #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
  4621. #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
  4622. #define KVM_STATS_BASE_SHIFT 8
  4623. #define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)
  4624. #define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT)
  4625. #define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT)
  4626. #define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2
  4627. struct kvm_stats_desc {
  4628. __u32 flags;
  4629. __s16 exponent;
  4630. __u16 size;
  4631. __u32 offset;
  4632. __u32 bucket_size;
  4633. char name[];
  4634. };
  4635. The ``flags`` field contains the type and unit of the statistics data described
  4636. by this descriptor. Its endianness is CPU native.
  4637. The following flags are supported:
  4638. Bits 0-3 of ``flags`` encode the type:
  4639. * ``KVM_STATS_TYPE_CUMULATIVE``
  4640. The statistics reports a cumulative count. The value of data can only be increased.
  4641. Most of the counters used in KVM are of this type.
  4642. The corresponding ``size`` field for this type is always 1.
  4643. All cumulative statistics data are read/write.
  4644. * ``KVM_STATS_TYPE_INSTANT``
  4645. The statistics reports an instantaneous value. Its value can be increased or
  4646. decreased. This type is usually used as a measurement of some resources,
  4647. like the number of dirty pages, the number of large pages, etc.
  4648. All instant statistics are read only.
  4649. The corresponding ``size`` field for this type is always 1.
  4650. * ``KVM_STATS_TYPE_PEAK``
  4651. The statistics data reports a peak value, for example the maximum number
  4652. of items in a hash table bucket, the longest time waited and so on.
  4653. The value of data can only be increased.
  4654. The corresponding ``size`` field for this type is always 1.
  4655. * ``KVM_STATS_TYPE_LINEAR_HIST``
  4656. The statistic is reported as a linear histogram. The number of
  4657. buckets is specified by the ``size`` field. The size of buckets is specified
  4658. by the ``hist_param`` field. The range of the Nth bucket (1 <= N < ``size``)
  4659. is [``hist_param``*(N-1), ``hist_param``*N), while the range of the last
  4660. bucket is [``hist_param``*(``size``-1), +INF). (+INF means positive infinity
  4661. value.)
  4662. * ``KVM_STATS_TYPE_LOG_HIST``
  4663. The statistic is reported as a logarithmic histogram. The number of
  4664. buckets is specified by the ``size`` field. The range of the first bucket is
  4665. [0, 1), while the range of the last bucket is [pow(2, ``size``-2), +INF).
  4666. Otherwise, The Nth bucket (1 < N < ``size``) covers
  4667. [pow(2, N-2), pow(2, N-1)).
  4668. Bits 4-7 of ``flags`` encode the unit:
  4669. * ``KVM_STATS_UNIT_NONE``
  4670. There is no unit for the value of statistics data. This usually means that
  4671. the value is a simple counter of an event.
  4672. * ``KVM_STATS_UNIT_BYTES``
  4673. It indicates that the statistics data is used to measure memory size, in the
  4674. unit of Byte, KiByte, MiByte, GiByte, etc. The unit of the data is
  4675. determined by the ``exponent`` field in the descriptor.
  4676. * ``KVM_STATS_UNIT_SECONDS``
  4677. It indicates that the statistics data is used to measure time or latency.
  4678. * ``KVM_STATS_UNIT_CYCLES``
  4679. It indicates that the statistics data is used to measure CPU clock cycles.
  4680. * ``KVM_STATS_UNIT_BOOLEAN``
  4681. It indicates that the statistic will always be either 0 or 1. Boolean
  4682. statistics of "peak" type will never go back from 1 to 0. Boolean
  4683. statistics can be linear histograms (with two buckets) but not logarithmic
  4684. histograms.
  4685. Note that, in the case of histograms, the unit applies to the bucket
  4686. ranges, while the bucket value indicates how many samples fell in the
  4687. bucket's range.
  4688. Bits 8-11 of ``flags``, together with ``exponent``, encode the scale of the
  4689. unit:
  4690. * ``KVM_STATS_BASE_POW10``
  4691. The scale is based on power of 10. It is used for measurement of time and
  4692. CPU clock cycles. For example, an exponent of -9 can be used with
  4693. ``KVM_STATS_UNIT_SECONDS`` to express that the unit is nanoseconds.
  4694. * ``KVM_STATS_BASE_POW2``
  4695. The scale is based on power of 2. It is used for measurement of memory size.
  4696. For example, an exponent of 20 can be used with ``KVM_STATS_UNIT_BYTES`` to
  4697. express that the unit is MiB.
  4698. The ``size`` field is the number of values of this statistics data. Its
  4699. value is usually 1 for most of simple statistics. 1 means it contains an
  4700. unsigned 64bit data.
  4701. The ``offset`` field is the offset from the start of Data Block to the start of
  4702. the corresponding statistics data.
  4703. The ``bucket_size`` field is used as a parameter for histogram statistics data.
  4704. It is only used by linear histogram statistics data, specifying the size of a
  4705. bucket in the unit expressed by bits 4-11 of ``flags`` together with ``exponent``.
  4706. The ``name`` field is the name string of the statistics data. The name string
  4707. starts at the end of ``struct kvm_stats_desc``. The maximum length including
  4708. the trailing ``'\0'``, is indicated by ``name_size`` in the header.
  4709. The Stats Data block contains an array of 64-bit values in the same order
  4710. as the descriptors in Descriptors block.
  4711. 4.134 KVM_GET_XSAVE2
  4712. --------------------
  4713. :Capability: KVM_CAP_XSAVE2
  4714. :Architectures: x86
  4715. :Type: vcpu ioctl
  4716. :Parameters: struct kvm_xsave (out)
  4717. :Returns: 0 on success, -1 on error
  4718. ::
  4719. struct kvm_xsave {
  4720. __u32 region[1024];
  4721. __u32 extra[0];
  4722. };
  4723. This ioctl would copy current vcpu's xsave struct to the userspace. It
  4724. copies as many bytes as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)
  4725. when invoked on the vm file descriptor. The size value returned by
  4726. KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2) will always be at least 4096.
  4727. Currently, it is only greater than 4096 if a dynamic feature has been
  4728. enabled with ``arch_prctl()``, but this may change in the future.
  4729. The offsets of the state save areas in struct kvm_xsave follow the contents
  4730. of CPUID leaf 0xD on the host.
  4731. 4.135 KVM_XEN_HVM_EVTCHN_SEND
  4732. -----------------------------
  4733. :Capability: KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND
  4734. :Architectures: x86
  4735. :Type: vm ioctl
  4736. :Parameters: struct kvm_irq_routing_xen_evtchn
  4737. :Returns: 0 on success, < 0 on error
  4738. ::
  4739. struct kvm_irq_routing_xen_evtchn {
  4740. __u32 port;
  4741. __u32 vcpu;
  4742. __u32 priority;
  4743. };
  4744. This ioctl injects an event channel interrupt directly to the guest vCPU.
  4745. 4.136 KVM_S390_PV_CPU_COMMAND
  4746. -----------------------------
  4747. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  4748. :Architectures: s390
  4749. :Type: vcpu ioctl
  4750. :Parameters: none
  4751. :Returns: 0 on success, < 0 on error
  4752. This ioctl closely mirrors `KVM_S390_PV_COMMAND` but handles requests
  4753. for vcpus. It re-uses the kvm_s390_pv_dmp struct and hence also shares
  4754. the command ids.
  4755. **command:**
  4756. KVM_PV_DUMP
  4757. Presents an API that provides calls which facilitate dumping a vcpu
  4758. of a protected VM.
  4759. **subcommand:**
  4760. KVM_PV_DUMP_CPU
  4761. Provides encrypted dump data like register values.
  4762. The length of the returned data is provided by uv_info.guest_cpu_stor_len.
  4763. 4.137 KVM_S390_ZPCI_OP
  4764. ----------------------
  4765. :Capability: KVM_CAP_S390_ZPCI_OP
  4766. :Architectures: s390
  4767. :Type: vm ioctl
  4768. :Parameters: struct kvm_s390_zpci_op (in)
  4769. :Returns: 0 on success, <0 on error
  4770. Used to manage hardware-assisted virtualization features for zPCI devices.
  4771. Parameters are specified via the following structure::
  4772. struct kvm_s390_zpci_op {
  4773. /* in */
  4774. __u32 fh; /* target device */
  4775. __u8 op; /* operation to perform */
  4776. __u8 pad[3];
  4777. union {
  4778. /* for KVM_S390_ZPCIOP_REG_AEN */
  4779. struct {
  4780. __u64 ibv; /* Guest addr of interrupt bit vector */
  4781. __u64 sb; /* Guest addr of summary bit */
  4782. __u32 flags;
  4783. __u32 noi; /* Number of interrupts */
  4784. __u8 isc; /* Guest interrupt subclass */
  4785. __u8 sbo; /* Offset of guest summary bit vector */
  4786. __u16 pad;
  4787. } reg_aen;
  4788. __u64 reserved[8];
  4789. } u;
  4790. };
  4791. The type of operation is specified in the "op" field.
  4792. KVM_S390_ZPCIOP_REG_AEN is used to register the VM for adapter event
  4793. notification interpretation, which will allow firmware delivery of adapter
  4794. events directly to the vm, with KVM providing a backup delivery mechanism;
  4795. KVM_S390_ZPCIOP_DEREG_AEN is used to subsequently disable interpretation of
  4796. adapter event notifications.
  4797. The target zPCI function must also be specified via the "fh" field. For the
  4798. KVM_S390_ZPCIOP_REG_AEN operation, additional information to establish firmware
  4799. delivery must be provided via the "reg_aen" struct.
  4800. The "pad" and "reserved" fields may be used for future extensions and should be
  4801. set to 0s by userspace.
  4802. 4.138 KVM_ARM_SET_COUNTER_OFFSET
  4803. --------------------------------
  4804. :Capability: KVM_CAP_COUNTER_OFFSET
  4805. :Architectures: arm64
  4806. :Type: vm ioctl
  4807. :Parameters: struct kvm_arm_counter_offset (in)
  4808. :Returns: 0 on success, < 0 on error
  4809. This capability indicates that userspace is able to apply a single VM-wide
  4810. offset to both the virtual and physical counters as viewed by the guest
  4811. using the KVM_ARM_SET_CNT_OFFSET ioctl and the following data structure:
  4812. ::
  4813. struct kvm_arm_counter_offset {
  4814. __u64 counter_offset;
  4815. __u64 reserved;
  4816. };
  4817. The offset describes a number of counter cycles that are subtracted from
  4818. both virtual and physical counter views (similar to the effects of the
  4819. CNTVOFF_EL2 and CNTPOFF_EL2 system registers, but only global). The offset
  4820. always applies to all vcpus (already created or created after this ioctl)
  4821. for this VM.
  4822. It is userspace's responsibility to compute the offset based, for example,
  4823. on previous values of the guest counters.
  4824. Any value other than 0 for the "reserved" field may result in an error
  4825. (-EINVAL) being returned. This ioctl can also return -EBUSY if any vcpu
  4826. ioctl is issued concurrently.
  4827. Note that using this ioctl results in KVM ignoring subsequent userspace
  4828. writes to the CNTVCT_EL0 and CNTPCT_EL0 registers using the SET_ONE_REG
  4829. interface. No error will be returned, but the resulting offset will not be
  4830. applied.
  4831. .. _KVM_ARM_GET_REG_WRITABLE_MASKS:
  4832. 4.139 KVM_ARM_GET_REG_WRITABLE_MASKS
  4833. -------------------------------------------
  4834. :Capability: KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES
  4835. :Architectures: arm64
  4836. :Type: vm ioctl
  4837. :Parameters: struct reg_mask_range (in/out)
  4838. :Returns: 0 on success, < 0 on error
  4839. ::
  4840. #define KVM_ARM_FEATURE_ID_RANGE 0
  4841. #define KVM_ARM_FEATURE_ID_RANGE_SIZE (3 * 8 * 8)
  4842. struct reg_mask_range {
  4843. __u64 addr; /* Pointer to mask array */
  4844. __u32 range; /* Requested range */
  4845. __u32 reserved[13];
  4846. };
  4847. This ioctl copies the writable masks for a selected range of registers to
  4848. userspace.
  4849. The ``addr`` field is a pointer to the destination array where KVM copies
  4850. the writable masks.
  4851. The ``range`` field indicates the requested range of registers.
  4852. ``KVM_CHECK_EXTENSION`` for the ``KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES``
  4853. capability returns the supported ranges, expressed as a set of flags. Each
  4854. flag's bit index represents a possible value for the ``range`` field.
  4855. All other values are reserved for future use and KVM may return an error.
  4856. The ``reserved[13]`` array is reserved for future use and should be 0, or
  4857. KVM may return an error.
  4858. KVM_ARM_FEATURE_ID_RANGE (0)
  4859. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  4860. The Feature ID range is defined as the AArch64 System register space with
  4861. op0==3, op1=={0, 1, 3}, CRn==0, CRm=={0-7}, op2=={0-7}.
  4862. The mask returned array pointed to by ``addr`` is indexed by the macro
  4863. ``ARM64_FEATURE_ID_RANGE_IDX(op0, op1, crn, crm, op2)``, allowing userspace
  4864. to know what fields can be changed for the system register described by
  4865. ``op0, op1, crn, crm, op2``. KVM rejects ID register values that describe a
  4866. superset of the features supported by the system.
  4867. 4.140 KVM_SET_USER_MEMORY_REGION2
  4868. ---------------------------------
  4869. :Capability: KVM_CAP_USER_MEMORY2
  4870. :Architectures: all
  4871. :Type: vm ioctl
  4872. :Parameters: struct kvm_userspace_memory_region2 (in)
  4873. :Returns: 0 on success, -1 on error
  4874. KVM_SET_USER_MEMORY_REGION2 is an extension to KVM_SET_USER_MEMORY_REGION that
  4875. allows mapping guest_memfd memory into a guest. All fields shared with
  4876. KVM_SET_USER_MEMORY_REGION identically. Userspace can set KVM_MEM_GUEST_MEMFD
  4877. in flags to have KVM bind the memory region to a given guest_memfd range of
  4878. [guest_memfd_offset, guest_memfd_offset + memory_size]. The target guest_memfd
  4879. must point at a file created via KVM_CREATE_GUEST_MEMFD on the current VM, and
  4880. the target range must not be bound to any other memory region. All standard
  4881. bounds checks apply (use common sense).
  4882. ::
  4883. struct kvm_userspace_memory_region2 {
  4884. __u32 slot;
  4885. __u32 flags;
  4886. __u64 guest_phys_addr;
  4887. __u64 memory_size; /* bytes */
  4888. __u64 userspace_addr; /* start of the userspace allocated memory */
  4889. __u64 guest_memfd_offset;
  4890. __u32 guest_memfd;
  4891. __u32 pad1;
  4892. __u64 pad2[14];
  4893. };
  4894. A KVM_MEM_GUEST_MEMFD region _must_ have a valid guest_memfd (private memory) and
  4895. userspace_addr (shared memory). However, "valid" for userspace_addr simply
  4896. means that the address itself must be a legal userspace address. The backing
  4897. mapping for userspace_addr is not required to be valid/populated at the time of
  4898. KVM_SET_USER_MEMORY_REGION2, e.g. shared memory can be lazily mapped/allocated
  4899. on-demand.
  4900. When mapping a gfn into the guest, KVM selects shared vs. private, i.e consumes
  4901. userspace_addr vs. guest_memfd, based on the gfn's KVM_MEMORY_ATTRIBUTE_PRIVATE
  4902. state. At VM creation time, all memory is shared, i.e. the PRIVATE attribute
  4903. is '0' for all gfns. Userspace can control whether memory is shared/private by
  4904. toggling KVM_MEMORY_ATTRIBUTE_PRIVATE via KVM_SET_MEMORY_ATTRIBUTES as needed.
  4905. S390:
  4906. ^^^^^
  4907. Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
  4908. Returns -EINVAL if called on a protected VM.
  4909. 4.141 KVM_SET_MEMORY_ATTRIBUTES
  4910. -------------------------------
  4911. :Capability: KVM_CAP_MEMORY_ATTRIBUTES
  4912. :Architectures: x86
  4913. :Type: vm ioctl
  4914. :Parameters: struct kvm_memory_attributes (in)
  4915. :Returns: 0 on success, <0 on error
  4916. KVM_SET_MEMORY_ATTRIBUTES allows userspace to set memory attributes for a range
  4917. of guest physical memory.
  4918. ::
  4919. struct kvm_memory_attributes {
  4920. __u64 address;
  4921. __u64 size;
  4922. __u64 attributes;
  4923. __u64 flags;
  4924. };
  4925. #define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3)
  4926. The address and size must be page aligned. The supported attributes can be
  4927. retrieved via ioctl(KVM_CHECK_EXTENSION) on KVM_CAP_MEMORY_ATTRIBUTES. If
  4928. executed on a VM, KVM_CAP_MEMORY_ATTRIBUTES precisely returns the attributes
  4929. supported by that VM. If executed at system scope, KVM_CAP_MEMORY_ATTRIBUTES
  4930. returns all attributes supported by KVM. The only attribute defined at this
  4931. time is KVM_MEMORY_ATTRIBUTE_PRIVATE, which marks the associated gfn as being
  4932. guest private memory.
  4933. Note, there is no "get" API. Userspace is responsible for explicitly tracking
  4934. the state of a gfn/page as needed.
  4935. The "flags" field is reserved for future extensions and must be '0'.
  4936. 4.142 KVM_CREATE_GUEST_MEMFD
  4937. ----------------------------
  4938. :Capability: KVM_CAP_GUEST_MEMFD
  4939. :Architectures: none
  4940. :Type: vm ioctl
  4941. :Parameters: struct kvm_create_guest_memfd(in)
  4942. :Returns: A file descriptor on success, <0 on error
  4943. KVM_CREATE_GUEST_MEMFD creates an anonymous file and returns a file descriptor
  4944. that refers to it. guest_memfd files are roughly analogous to files created
  4945. via memfd_create(), e.g. guest_memfd files live in RAM, have volatile storage,
  4946. and are automatically released when the last reference is dropped. Unlike
  4947. "regular" memfd_create() files, guest_memfd files are bound to their owning
  4948. virtual machine (see below), cannot be mapped, read, or written by userspace,
  4949. and cannot be resized (guest_memfd files do however support PUNCH_HOLE).
  4950. ::
  4951. struct kvm_create_guest_memfd {
  4952. __u64 size;
  4953. __u64 flags;
  4954. __u64 reserved[6];
  4955. };
  4956. Conceptually, the inode backing a guest_memfd file represents physical memory,
  4957. i.e. is coupled to the virtual machine as a thing, not to a "struct kvm". The
  4958. file itself, which is bound to a "struct kvm", is that instance's view of the
  4959. underlying memory, e.g. effectively provides the translation of guest addresses
  4960. to host memory. This allows for use cases where multiple KVM structures are
  4961. used to manage a single virtual machine, e.g. when performing intrahost
  4962. migration of a virtual machine.
  4963. KVM currently only supports mapping guest_memfd via KVM_SET_USER_MEMORY_REGION2,
  4964. and more specifically via the guest_memfd and guest_memfd_offset fields in
  4965. "struct kvm_userspace_memory_region2", where guest_memfd_offset is the offset
  4966. into the guest_memfd instance. For a given guest_memfd file, there can be at
  4967. most one mapping per page, i.e. binding multiple memory regions to a single
  4968. guest_memfd range is not allowed (any number of memory regions can be bound to
  4969. a single guest_memfd file, but the bound ranges must not overlap).
  4970. See KVM_SET_USER_MEMORY_REGION2 for additional details.
  4971. 4.143 KVM_PRE_FAULT_MEMORY
  4972. ---------------------------
  4973. :Capability: KVM_CAP_PRE_FAULT_MEMORY
  4974. :Architectures: none
  4975. :Type: vcpu ioctl
  4976. :Parameters: struct kvm_pre_fault_memory (in/out)
  4977. :Returns: 0 if at least one page is processed, < 0 on error
  4978. Errors:
  4979. ========== ===============================================================
  4980. EINVAL The specified `gpa` and `size` were invalid (e.g. not
  4981. page aligned, causes an overflow, or size is zero).
  4982. ENOENT The specified `gpa` is outside defined memslots.
  4983. EINTR An unmasked signal is pending and no page was processed.
  4984. EFAULT The parameter address was invalid.
  4985. EOPNOTSUPP Mapping memory for a GPA is unsupported by the
  4986. hypervisor, and/or for the current vCPU state/mode.
  4987. EIO unexpected error conditions (also causes a WARN)
  4988. ========== ===============================================================
  4989. ::
  4990. struct kvm_pre_fault_memory {
  4991. /* in/out */
  4992. __u64 gpa;
  4993. __u64 size;
  4994. /* in */
  4995. __u64 flags;
  4996. __u64 padding[5];
  4997. };
  4998. KVM_PRE_FAULT_MEMORY populates KVM's stage-2 page tables used to map memory
  4999. for the current vCPU state. KVM maps memory as if the vCPU generated a
  5000. stage-2 read page fault, e.g. faults in memory as needed, but doesn't break
  5001. CoW. However, KVM does not mark any newly created stage-2 PTE as Accessed.
  5002. In the case of confidential VM types where there is an initial set up of
  5003. private guest memory before the guest is 'finalized'/measured, this ioctl
  5004. should only be issued after completing all the necessary setup to put the
  5005. guest into a 'finalized' state so that the above semantics can be reliably
  5006. ensured.
  5007. In some cases, multiple vCPUs might share the page tables. In this
  5008. case, the ioctl can be called in parallel.
  5009. When the ioctl returns, the input values are updated to point to the
  5010. remaining range. If `size` > 0 on return, the caller can just issue
  5011. the ioctl again with the same `struct kvm_map_memory` argument.
  5012. Shadow page tables cannot support this ioctl because they
  5013. are indexed by virtual address or nested guest physical address.
  5014. Calling this ioctl when the guest is using shadow page tables (for
  5015. example because it is running a nested guest with nested page tables)
  5016. will fail with `EOPNOTSUPP` even if `KVM_CHECK_EXTENSION` reports
  5017. the capability to be present.
  5018. `flags` must currently be zero.
  5019. 5. The kvm_run structure
  5020. ========================
  5021. Application code obtains a pointer to the kvm_run structure by
  5022. mmap()ing a vcpu fd. From that point, application code can control
  5023. execution by changing fields in kvm_run prior to calling the KVM_RUN
  5024. ioctl, and obtain information about the reason KVM_RUN returned by
  5025. looking up structure members.
  5026. ::
  5027. struct kvm_run {
  5028. /* in */
  5029. __u8 request_interrupt_window;
  5030. Request that KVM_RUN return when it becomes possible to inject external
  5031. interrupts into the guest. Useful in conjunction with KVM_INTERRUPT.
  5032. ::
  5033. __u8 immediate_exit;
  5034. This field is polled once when KVM_RUN starts; if non-zero, KVM_RUN
  5035. exits immediately, returning -EINTR. In the common scenario where a
  5036. signal is used to "kick" a VCPU out of KVM_RUN, this field can be used
  5037. to avoid usage of KVM_SET_SIGNAL_MASK, which has worse scalability.
  5038. Rather than blocking the signal outside KVM_RUN, userspace can set up
  5039. a signal handler that sets run->immediate_exit to a non-zero value.
  5040. This field is ignored if KVM_CAP_IMMEDIATE_EXIT is not available.
  5041. ::
  5042. __u8 padding1[6];
  5043. /* out */
  5044. __u32 exit_reason;
  5045. When KVM_RUN has returned successfully (return value 0), this informs
  5046. application code why KVM_RUN has returned. Allowable values for this
  5047. field are detailed below.
  5048. ::
  5049. __u8 ready_for_interrupt_injection;
  5050. If request_interrupt_window has been specified, this field indicates
  5051. an interrupt can be injected now with KVM_INTERRUPT.
  5052. ::
  5053. __u8 if_flag;
  5054. The value of the current interrupt flag. Only valid if in-kernel
  5055. local APIC is not used.
  5056. ::
  5057. __u16 flags;
  5058. More architecture-specific flags detailing state of the VCPU that may
  5059. affect the device's behavior. Current defined flags::
  5060. /* x86, set if the VCPU is in system management mode */
  5061. #define KVM_RUN_X86_SMM (1 << 0)
  5062. /* x86, set if bus lock detected in VM */
  5063. #define KVM_RUN_X86_BUS_LOCK (1 << 1)
  5064. /* x86, set if the VCPU is executing a nested (L2) guest */
  5065. #define KVM_RUN_X86_GUEST_MODE (1 << 2)
  5066. /* arm64, set for KVM_EXIT_DEBUG */
  5067. #define KVM_DEBUG_ARCH_HSR_HIGH_VALID (1 << 0)
  5068. ::
  5069. /* in (pre_kvm_run), out (post_kvm_run) */
  5070. __u64 cr8;
  5071. The value of the cr8 register. Only valid if in-kernel local APIC is
  5072. not used. Both input and output.
  5073. ::
  5074. __u64 apic_base;
  5075. The value of the APIC BASE msr. Only valid if in-kernel local
  5076. APIC is not used. Both input and output.
  5077. ::
  5078. union {
  5079. /* KVM_EXIT_UNKNOWN */
  5080. struct {
  5081. __u64 hardware_exit_reason;
  5082. } hw;
  5083. If exit_reason is KVM_EXIT_UNKNOWN, the vcpu has exited due to unknown
  5084. reasons. Further architecture-specific information is available in
  5085. hardware_exit_reason.
  5086. ::
  5087. /* KVM_EXIT_FAIL_ENTRY */
  5088. struct {
  5089. __u64 hardware_entry_failure_reason;
  5090. __u32 cpu; /* if KVM_LAST_CPU */
  5091. } fail_entry;
  5092. If exit_reason is KVM_EXIT_FAIL_ENTRY, the vcpu could not be run due
  5093. to unknown reasons. Further architecture-specific information is
  5094. available in hardware_entry_failure_reason.
  5095. ::
  5096. /* KVM_EXIT_EXCEPTION */
  5097. struct {
  5098. __u32 exception;
  5099. __u32 error_code;
  5100. } ex;
  5101. Unused.
  5102. ::
  5103. /* KVM_EXIT_IO */
  5104. struct {
  5105. #define KVM_EXIT_IO_IN 0
  5106. #define KVM_EXIT_IO_OUT 1
  5107. __u8 direction;
  5108. __u8 size; /* bytes */
  5109. __u16 port;
  5110. __u32 count;
  5111. __u64 data_offset; /* relative to kvm_run start */
  5112. } io;
  5113. If exit_reason is KVM_EXIT_IO, then the vcpu has
  5114. executed a port I/O instruction which could not be satisfied by kvm.
  5115. data_offset describes where the data is located (KVM_EXIT_IO_OUT) or
  5116. where kvm expects application code to place the data for the next
  5117. KVM_RUN invocation (KVM_EXIT_IO_IN). Data format is a packed array.
  5118. ::
  5119. /* KVM_EXIT_DEBUG */
  5120. struct {
  5121. struct kvm_debug_exit_arch arch;
  5122. } debug;
  5123. If the exit_reason is KVM_EXIT_DEBUG, then a vcpu is processing a debug event
  5124. for which architecture specific information is returned.
  5125. ::
  5126. /* KVM_EXIT_MMIO */
  5127. struct {
  5128. __u64 phys_addr;
  5129. __u8 data[8];
  5130. __u32 len;
  5131. __u8 is_write;
  5132. } mmio;
  5133. If exit_reason is KVM_EXIT_MMIO, then the vcpu has
  5134. executed a memory-mapped I/O instruction which could not be satisfied
  5135. by kvm. The 'data' member contains the written data if 'is_write' is
  5136. true, and should be filled by application code otherwise.
  5137. The 'data' member contains, in its first 'len' bytes, the value as it would
  5138. appear if the VCPU performed a load or store of the appropriate width directly
  5139. to the byte array.
  5140. .. note::
  5141. For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR, KVM_EXIT_XEN,
  5142. KVM_EXIT_EPR, KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR the corresponding
  5143. operations are complete (and guest state is consistent) only after userspace
  5144. has re-entered the kernel with KVM_RUN. The kernel side will first finish
  5145. incomplete operations and then check for pending signals.
  5146. The pending state of the operation is not preserved in state which is
  5147. visible to userspace, thus userspace should ensure that the operation is
  5148. completed before performing a live migration. Userspace can re-enter the
  5149. guest with an unmasked signal pending or with the immediate_exit field set
  5150. to complete pending operations without allowing any further instructions
  5151. to be executed.
  5152. ::
  5153. /* KVM_EXIT_HYPERCALL */
  5154. struct {
  5155. __u64 nr;
  5156. __u64 args[6];
  5157. __u64 ret;
  5158. __u64 flags;
  5159. } hypercall;
  5160. It is strongly recommended that userspace use ``KVM_EXIT_IO`` (x86) or
  5161. ``KVM_EXIT_MMIO`` (all except s390) to implement functionality that
  5162. requires a guest to interact with host userspace.
  5163. .. note:: KVM_EXIT_IO is significantly faster than KVM_EXIT_MMIO.
  5164. For arm64:
  5165. ----------
  5166. SMCCC exits can be enabled depending on the configuration of the SMCCC
  5167. filter. See the Documentation/virt/kvm/devices/vm.rst
  5168. ``KVM_ARM_SMCCC_FILTER`` for more details.
  5169. ``nr`` contains the function ID of the guest's SMCCC call. Userspace is
  5170. expected to use the ``KVM_GET_ONE_REG`` ioctl to retrieve the call
  5171. parameters from the vCPU's GPRs.
  5172. Definition of ``flags``:
  5173. - ``KVM_HYPERCALL_EXIT_SMC``: Indicates that the guest used the SMC
  5174. conduit to initiate the SMCCC call. If this bit is 0 then the guest
  5175. used the HVC conduit for the SMCCC call.
  5176. - ``KVM_HYPERCALL_EXIT_16BIT``: Indicates that the guest used a 16bit
  5177. instruction to initiate the SMCCC call. If this bit is 0 then the
  5178. guest used a 32bit instruction. An AArch64 guest always has this
  5179. bit set to 0.
  5180. At the point of exit, PC points to the instruction immediately following
  5181. the trapping instruction.
  5182. ::
  5183. /* KVM_EXIT_TPR_ACCESS */
  5184. struct {
  5185. __u64 rip;
  5186. __u32 is_write;
  5187. __u32 pad;
  5188. } tpr_access;
  5189. To be documented (KVM_TPR_ACCESS_REPORTING).
  5190. ::
  5191. /* KVM_EXIT_S390_SIEIC */
  5192. struct {
  5193. __u8 icptcode;
  5194. __u64 mask; /* psw upper half */
  5195. __u64 addr; /* psw lower half */
  5196. __u16 ipa;
  5197. __u32 ipb;
  5198. } s390_sieic;
  5199. s390 specific.
  5200. ::
  5201. /* KVM_EXIT_S390_RESET */
  5202. #define KVM_S390_RESET_POR 1
  5203. #define KVM_S390_RESET_CLEAR 2
  5204. #define KVM_S390_RESET_SUBSYSTEM 4
  5205. #define KVM_S390_RESET_CPU_INIT 8
  5206. #define KVM_S390_RESET_IPL 16
  5207. __u64 s390_reset_flags;
  5208. s390 specific.
  5209. ::
  5210. /* KVM_EXIT_S390_UCONTROL */
  5211. struct {
  5212. __u64 trans_exc_code;
  5213. __u32 pgm_code;
  5214. } s390_ucontrol;
  5215. s390 specific. A page fault has occurred for a user controlled virtual
  5216. machine (KVM_VM_S390_UNCONTROL) on its host page table that cannot be
  5217. resolved by the kernel.
  5218. The program code and the translation exception code that were placed
  5219. in the cpu's lowcore are presented here as defined by the z Architecture
  5220. Principles of Operation Book in the Chapter for Dynamic Address Translation
  5221. (DAT)
  5222. ::
  5223. /* KVM_EXIT_DCR */
  5224. struct {
  5225. __u32 dcrn;
  5226. __u32 data;
  5227. __u8 is_write;
  5228. } dcr;
  5229. Deprecated - was used for 440 KVM.
  5230. ::
  5231. /* KVM_EXIT_OSI */
  5232. struct {
  5233. __u64 gprs[32];
  5234. } osi;
  5235. MOL uses a special hypercall interface it calls 'OSI'. To enable it, we catch
  5236. hypercalls and exit with this exit struct that contains all the guest gprs.
  5237. If exit_reason is KVM_EXIT_OSI, then the vcpu has triggered such a hypercall.
  5238. Userspace can now handle the hypercall and when it's done modify the gprs as
  5239. necessary. Upon guest entry all guest GPRs will then be replaced by the values
  5240. in this struct.
  5241. ::
  5242. /* KVM_EXIT_PAPR_HCALL */
  5243. struct {
  5244. __u64 nr;
  5245. __u64 ret;
  5246. __u64 args[9];
  5247. } papr_hcall;
  5248. This is used on 64-bit PowerPC when emulating a pSeries partition,
  5249. e.g. with the 'pseries' machine type in qemu. It occurs when the
  5250. guest does a hypercall using the 'sc 1' instruction. The 'nr' field
  5251. contains the hypercall number (from the guest R3), and 'args' contains
  5252. the arguments (from the guest R4 - R12). Userspace should put the
  5253. return code in 'ret' and any extra returned values in args[].
  5254. The possible hypercalls are defined in the Power Architecture Platform
  5255. Requirements (PAPR) document available from www.power.org (free
  5256. developer registration required to access it).
  5257. ::
  5258. /* KVM_EXIT_S390_TSCH */
  5259. struct {
  5260. __u16 subchannel_id;
  5261. __u16 subchannel_nr;
  5262. __u32 io_int_parm;
  5263. __u32 io_int_word;
  5264. __u32 ipb;
  5265. __u8 dequeued;
  5266. } s390_tsch;
  5267. s390 specific. This exit occurs when KVM_CAP_S390_CSS_SUPPORT has been enabled
  5268. and TEST SUBCHANNEL was intercepted. If dequeued is set, a pending I/O
  5269. interrupt for the target subchannel has been dequeued and subchannel_id,
  5270. subchannel_nr, io_int_parm and io_int_word contain the parameters for that
  5271. interrupt. ipb is needed for instruction parameter decoding.
  5272. ::
  5273. /* KVM_EXIT_EPR */
  5274. struct {
  5275. __u32 epr;
  5276. } epr;
  5277. On FSL BookE PowerPC chips, the interrupt controller has a fast patch
  5278. interrupt acknowledge path to the core. When the core successfully
  5279. delivers an interrupt, it automatically populates the EPR register with
  5280. the interrupt vector number and acknowledges the interrupt inside
  5281. the interrupt controller.
  5282. In case the interrupt controller lives in user space, we need to do
  5283. the interrupt acknowledge cycle through it to fetch the next to be
  5284. delivered interrupt vector using this exit.
  5285. It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
  5286. external interrupt has just been delivered into the guest. User space
  5287. should put the acknowledged interrupt vector into the 'epr' field.
  5288. ::
  5289. /* KVM_EXIT_SYSTEM_EVENT */
  5290. struct {
  5291. #define KVM_SYSTEM_EVENT_SHUTDOWN 1
  5292. #define KVM_SYSTEM_EVENT_RESET 2
  5293. #define KVM_SYSTEM_EVENT_CRASH 3
  5294. #define KVM_SYSTEM_EVENT_WAKEUP 4
  5295. #define KVM_SYSTEM_EVENT_SUSPEND 5
  5296. #define KVM_SYSTEM_EVENT_SEV_TERM 6
  5297. __u32 type;
  5298. __u32 ndata;
  5299. __u64 data[16];
  5300. } system_event;
  5301. If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered
  5302. a system-level event using some architecture specific mechanism (hypercall
  5303. or some special instruction). In case of ARM64, this is triggered using
  5304. HVC instruction based PSCI call from the vcpu.
  5305. The 'type' field describes the system-level event type.
  5306. Valid values for 'type' are:
  5307. - KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the
  5308. VM. Userspace is not obliged to honour this, and if it does honour
  5309. this does not need to destroy the VM synchronously (ie it may call
  5310. KVM_RUN again before shutdown finally occurs).
  5311. - KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM.
  5312. As with SHUTDOWN, userspace can choose to ignore the request, or
  5313. to schedule the reset to occur in the future and may call KVM_RUN again.
  5314. - KVM_SYSTEM_EVENT_CRASH -- the guest crash occurred and the guest
  5315. has requested a crash condition maintenance. Userspace can choose
  5316. to ignore the request, or to gather VM memory core dump and/or
  5317. reset/shutdown of the VM.
  5318. - KVM_SYSTEM_EVENT_SEV_TERM -- an AMD SEV guest requested termination.
  5319. The guest physical address of the guest's GHCB is stored in `data[0]`.
  5320. - KVM_SYSTEM_EVENT_WAKEUP -- the exiting vCPU is in a suspended state and
  5321. KVM has recognized a wakeup event. Userspace may honor this event by
  5322. marking the exiting vCPU as runnable, or deny it and call KVM_RUN again.
  5323. - KVM_SYSTEM_EVENT_SUSPEND -- the guest has requested a suspension of
  5324. the VM.
  5325. If KVM_CAP_SYSTEM_EVENT_DATA is present, the 'data' field can contain
  5326. architecture specific information for the system-level event. Only
  5327. the first `ndata` items (possibly zero) of the data array are valid.
  5328. - for arm64, data[0] is set to KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 if
  5329. the guest issued a SYSTEM_RESET2 call according to v1.1 of the PSCI
  5330. specification.
  5331. - for RISC-V, data[0] is set to the value of the second argument of the
  5332. ``sbi_system_reset`` call.
  5333. Previous versions of Linux defined a `flags` member in this struct. The
  5334. field is now aliased to `data[0]`. Userspace can assume that it is only
  5335. written if ndata is greater than 0.
  5336. For arm/arm64:
  5337. --------------
  5338. KVM_SYSTEM_EVENT_SUSPEND exits are enabled with the
  5339. KVM_CAP_ARM_SYSTEM_SUSPEND VM capability. If a guest invokes the PSCI
  5340. SYSTEM_SUSPEND function, KVM will exit to userspace with this event
  5341. type.
  5342. It is the sole responsibility of userspace to implement the PSCI
  5343. SYSTEM_SUSPEND call according to ARM DEN0022D.b 5.19 "SYSTEM_SUSPEND".
  5344. KVM does not change the vCPU's state before exiting to userspace, so
  5345. the call parameters are left in-place in the vCPU registers.
  5346. Userspace is _required_ to take action for such an exit. It must
  5347. either:
  5348. - Honor the guest request to suspend the VM. Userspace can request
  5349. in-kernel emulation of suspension by setting the calling vCPU's
  5350. state to KVM_MP_STATE_SUSPENDED. Userspace must configure the vCPU's
  5351. state according to the parameters passed to the PSCI function when
  5352. the calling vCPU is resumed. See ARM DEN0022D.b 5.19.1 "Intended use"
  5353. for details on the function parameters.
  5354. - Deny the guest request to suspend the VM. See ARM DEN0022D.b 5.19.2
  5355. "Caller responsibilities" for possible return values.
  5356. ::
  5357. /* KVM_EXIT_IOAPIC_EOI */
  5358. struct {
  5359. __u8 vector;
  5360. } eoi;
  5361. Indicates that the VCPU's in-kernel local APIC received an EOI for a
  5362. level-triggered IOAPIC interrupt. This exit only triggers when the
  5363. IOAPIC is implemented in userspace (i.e. KVM_CAP_SPLIT_IRQCHIP is enabled);
  5364. the userspace IOAPIC should process the EOI and retrigger the interrupt if
  5365. it is still asserted. Vector is the LAPIC interrupt vector for which the
  5366. EOI was received.
  5367. ::
  5368. struct kvm_hyperv_exit {
  5369. #define KVM_EXIT_HYPERV_SYNIC 1
  5370. #define KVM_EXIT_HYPERV_HCALL 2
  5371. #define KVM_EXIT_HYPERV_SYNDBG 3
  5372. __u32 type;
  5373. __u32 pad1;
  5374. union {
  5375. struct {
  5376. __u32 msr;
  5377. __u32 pad2;
  5378. __u64 control;
  5379. __u64 evt_page;
  5380. __u64 msg_page;
  5381. } synic;
  5382. struct {
  5383. __u64 input;
  5384. __u64 result;
  5385. __u64 params[2];
  5386. } hcall;
  5387. struct {
  5388. __u32 msr;
  5389. __u32 pad2;
  5390. __u64 control;
  5391. __u64 status;
  5392. __u64 send_page;
  5393. __u64 recv_page;
  5394. __u64 pending_page;
  5395. } syndbg;
  5396. } u;
  5397. };
  5398. /* KVM_EXIT_HYPERV */
  5399. struct kvm_hyperv_exit hyperv;
  5400. Indicates that the VCPU exits into userspace to process some tasks
  5401. related to Hyper-V emulation.
  5402. Valid values for 'type' are:
  5403. - KVM_EXIT_HYPERV_SYNIC -- synchronously notify user-space about
  5404. Hyper-V SynIC state change. Notification is used to remap SynIC
  5405. event/message pages and to enable/disable SynIC messages/events processing
  5406. in userspace.
  5407. - KVM_EXIT_HYPERV_SYNDBG -- synchronously notify user-space about
  5408. Hyper-V Synthetic debugger state change. Notification is used to either update
  5409. the pending_page location or to send a control command (send the buffer located
  5410. in send_page or recv a buffer to recv_page).
  5411. ::
  5412. /* KVM_EXIT_ARM_NISV */
  5413. struct {
  5414. __u64 esr_iss;
  5415. __u64 fault_ipa;
  5416. } arm_nisv;
  5417. Used on arm64 systems. If a guest accesses memory not in a memslot,
  5418. KVM will typically return to userspace and ask it to do MMIO emulation on its
  5419. behalf. However, for certain classes of instructions, no instruction decode
  5420. (direction, length of memory access) is provided, and fetching and decoding
  5421. the instruction from the VM is overly complicated to live in the kernel.
  5422. Historically, when this situation occurred, KVM would print a warning and kill
  5423. the VM. KVM assumed that if the guest accessed non-memslot memory, it was
  5424. trying to do I/O, which just couldn't be emulated, and the warning message was
  5425. phrased accordingly. However, what happened more often was that a guest bug
  5426. caused access outside the guest memory areas which should lead to a more
  5427. meaningful warning message and an external abort in the guest, if the access
  5428. did not fall within an I/O window.
  5429. Userspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable
  5430. this capability at VM creation. Once this is done, these types of errors will
  5431. instead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from
  5432. the ESR_EL2 in the esr_iss field, and the faulting IPA in the fault_ipa field.
  5433. Userspace can either fix up the access if it's actually an I/O access by
  5434. decoding the instruction from guest memory (if it's very brave) and continue
  5435. executing the guest, or it can decide to suspend, dump, or restart the guest.
  5436. Note that KVM does not skip the faulting instruction as it does for
  5437. KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state
  5438. if it decides to decode and emulate the instruction.
  5439. This feature isn't available to protected VMs, as userspace does not
  5440. have access to the state that is required to perform the emulation.
  5441. Instead, a data abort exception is directly injected in the guest.
  5442. Note that although KVM_CAP_ARM_NISV_TO_USER will be reported if
  5443. queried outside of a protected VM context, the feature will not be
  5444. exposed if queried on a protected VM file descriptor.
  5445. ::
  5446. /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */
  5447. struct {
  5448. __u8 error; /* user -> kernel */
  5449. __u8 pad[7];
  5450. __u32 reason; /* kernel -> user */
  5451. __u32 index; /* kernel -> user */
  5452. __u64 data; /* kernel <-> user */
  5453. } msr;
  5454. Used on x86 systems. When the VM capability KVM_CAP_X86_USER_SPACE_MSR is
  5455. enabled, MSR accesses to registers that would invoke a #GP by KVM kernel code
  5456. may instead trigger a KVM_EXIT_X86_RDMSR exit for reads and KVM_EXIT_X86_WRMSR
  5457. exit for writes.
  5458. The "reason" field specifies why the MSR interception occurred. Userspace will
  5459. only receive MSR exits when a particular reason was requested during through
  5460. ENABLE_CAP. Currently valid exit reasons are:
  5461. ============================ ========================================
  5462. KVM_MSR_EXIT_REASON_UNKNOWN access to MSR that is unknown to KVM
  5463. KVM_MSR_EXIT_REASON_INVAL access to invalid MSRs or reserved bits
  5464. KVM_MSR_EXIT_REASON_FILTER access blocked by KVM_X86_SET_MSR_FILTER
  5465. ============================ ========================================
  5466. For KVM_EXIT_X86_RDMSR, the "index" field tells userspace which MSR the guest
  5467. wants to read. To respond to this request with a successful read, userspace
  5468. writes the respective data into the "data" field and must continue guest
  5469. execution to ensure the read data is transferred into guest register state.
  5470. If the RDMSR request was unsuccessful, userspace indicates that with a "1" in
  5471. the "error" field. This will inject a #GP into the guest when the VCPU is
  5472. executed again.
  5473. For KVM_EXIT_X86_WRMSR, the "index" field tells userspace which MSR the guest
  5474. wants to write. Once finished processing the event, userspace must continue
  5475. vCPU execution. If the MSR write was unsuccessful, userspace also sets the
  5476. "error" field to "1".
  5477. See KVM_X86_SET_MSR_FILTER for details on the interaction with MSR filtering.
  5478. ::
  5479. struct kvm_xen_exit {
  5480. #define KVM_EXIT_XEN_HCALL 1
  5481. __u32 type;
  5482. union {
  5483. struct {
  5484. __u32 longmode;
  5485. __u32 cpl;
  5486. __u64 input;
  5487. __u64 result;
  5488. __u64 params[6];
  5489. } hcall;
  5490. } u;
  5491. };
  5492. /* KVM_EXIT_XEN */
  5493. struct kvm_hyperv_exit xen;
  5494. Indicates that the VCPU exits into userspace to process some tasks
  5495. related to Xen emulation.
  5496. Valid values for 'type' are:
  5497. - KVM_EXIT_XEN_HCALL -- synchronously notify user-space about Xen hypercall.
  5498. Userspace is expected to place the hypercall result into the appropriate
  5499. field before invoking KVM_RUN again.
  5500. ::
  5501. /* KVM_EXIT_RISCV_SBI */
  5502. struct {
  5503. unsigned long extension_id;
  5504. unsigned long function_id;
  5505. unsigned long args[6];
  5506. unsigned long ret[2];
  5507. } riscv_sbi;
  5508. If exit reason is KVM_EXIT_RISCV_SBI then it indicates that the VCPU has
  5509. done a SBI call which is not handled by KVM RISC-V kernel module. The details
  5510. of the SBI call are available in 'riscv_sbi' member of kvm_run structure. The
  5511. 'extension_id' field of 'riscv_sbi' represents SBI extension ID whereas the
  5512. 'function_id' field represents function ID of given SBI extension. The 'args'
  5513. array field of 'riscv_sbi' represents parameters for the SBI call and 'ret'
  5514. array field represents return values. The userspace should update the return
  5515. values of SBI call before resuming the VCPU. For more details on RISC-V SBI
  5516. spec refer, https://github.com/riscv/riscv-sbi-doc.
  5517. ::
  5518. /* KVM_EXIT_MEMORY_FAULT */
  5519. struct {
  5520. #define KVM_MEMORY_EXIT_FLAG_PRIVATE (1ULL << 3)
  5521. __u64 flags;
  5522. __u64 gpa;
  5523. __u64 size;
  5524. } memory_fault;
  5525. KVM_EXIT_MEMORY_FAULT indicates the vCPU has encountered a memory fault that
  5526. could not be resolved by KVM. The 'gpa' and 'size' (in bytes) describe the
  5527. guest physical address range [gpa, gpa + size) of the fault. The 'flags' field
  5528. describes properties of the faulting access that are likely pertinent:
  5529. - KVM_MEMORY_EXIT_FLAG_PRIVATE - When set, indicates the memory fault occurred
  5530. on a private memory access. When clear, indicates the fault occurred on a
  5531. shared access.
  5532. Note! KVM_EXIT_MEMORY_FAULT is unique among all KVM exit reasons in that it
  5533. accompanies a return code of '-1', not '0'! errno will always be set to EFAULT
  5534. or EHWPOISON when KVM exits with KVM_EXIT_MEMORY_FAULT, userspace should assume
  5535. kvm_run.exit_reason is stale/undefined for all other error numbers.
  5536. ::
  5537. /* KVM_EXIT_NOTIFY */
  5538. struct {
  5539. #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0)
  5540. __u32 flags;
  5541. } notify;
  5542. Used on x86 systems. When the VM capability KVM_CAP_X86_NOTIFY_VMEXIT is
  5543. enabled, a VM exit generated if no event window occurs in VM non-root mode
  5544. for a specified amount of time. Once KVM_X86_NOTIFY_VMEXIT_USER is set when
  5545. enabling the cap, it would exit to userspace with the exit reason
  5546. KVM_EXIT_NOTIFY for further handling. The "flags" field contains more
  5547. detailed info.
  5548. The valid value for 'flags' is:
  5549. - KVM_NOTIFY_CONTEXT_INVALID -- the VM context is corrupted and not valid
  5550. in VMCS. It would run into unknown result if resume the target VM.
  5551. ::
  5552. /* Fix the size of the union. */
  5553. char padding[256];
  5554. };
  5555. /*
  5556. * shared registers between kvm and userspace.
  5557. * kvm_valid_regs specifies the register classes set by the host
  5558. * kvm_dirty_regs specified the register classes dirtied by userspace
  5559. * struct kvm_sync_regs is architecture specific, as well as the
  5560. * bits for kvm_valid_regs and kvm_dirty_regs
  5561. */
  5562. __u64 kvm_valid_regs;
  5563. __u64 kvm_dirty_regs;
  5564. union {
  5565. struct kvm_sync_regs regs;
  5566. char padding[SYNC_REGS_SIZE_BYTES];
  5567. } s;
  5568. If KVM_CAP_SYNC_REGS is defined, these fields allow userspace to access
  5569. certain guest registers without having to call SET/GET_*REGS. Thus we can
  5570. avoid some system call overhead if userspace has to handle the exit.
  5571. Userspace can query the validity of the structure by checking
  5572. kvm_valid_regs for specific bits. These bits are architecture specific
  5573. and usually define the validity of a groups of registers. (e.g. one bit
  5574. for general purpose registers)
  5575. Please note that the kernel is allowed to use the kvm_run structure as the
  5576. primary storage for certain register types. Therefore, the kernel may use the
  5577. values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set.
  5578. 6. Capabilities that can be enabled on vCPUs
  5579. ============================================
  5580. There are certain capabilities that change the behavior of the virtual CPU or
  5581. the virtual machine when enabled. To enable them, please see section 4.37.
  5582. Below you can find a list of capabilities and what their effect on the vCPU or
  5583. the virtual machine is when enabling them.
  5584. The following information is provided along with the description:
  5585. Architectures:
  5586. which instruction set architectures provide this ioctl.
  5587. x86 includes both i386 and x86_64.
  5588. Target:
  5589. whether this is a per-vcpu or per-vm capability.
  5590. Parameters:
  5591. what parameters are accepted by the capability.
  5592. Returns:
  5593. the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  5594. are not detailed, but errors with specific meanings are.
  5595. 6.1 KVM_CAP_PPC_OSI
  5596. -------------------
  5597. :Architectures: ppc
  5598. :Target: vcpu
  5599. :Parameters: none
  5600. :Returns: 0 on success; -1 on error
  5601. This capability enables interception of OSI hypercalls that otherwise would
  5602. be treated as normal system calls to be injected into the guest. OSI hypercalls
  5603. were invented by Mac-on-Linux to have a standardized communication mechanism
  5604. between the guest and the host.
  5605. When this capability is enabled, KVM_EXIT_OSI can occur.
  5606. 6.2 KVM_CAP_PPC_PAPR
  5607. --------------------
  5608. :Architectures: ppc
  5609. :Target: vcpu
  5610. :Parameters: none
  5611. :Returns: 0 on success; -1 on error
  5612. This capability enables interception of PAPR hypercalls. PAPR hypercalls are
  5613. done using the hypercall instruction "sc 1".
  5614. It also sets the guest privilege level to "supervisor" mode. Usually the guest
  5615. runs in "hypervisor" privilege mode with a few missing features.
  5616. In addition to the above, it changes the semantics of SDR1. In this mode, the
  5617. HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
  5618. HTAB invisible to the guest.
  5619. When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
  5620. 6.3 KVM_CAP_SW_TLB
  5621. ------------------
  5622. :Architectures: ppc
  5623. :Target: vcpu
  5624. :Parameters: args[0] is the address of a struct kvm_config_tlb
  5625. :Returns: 0 on success; -1 on error
  5626. ::
  5627. struct kvm_config_tlb {
  5628. __u64 params;
  5629. __u64 array;
  5630. __u32 mmu_type;
  5631. __u32 array_len;
  5632. };
  5633. Configures the virtual CPU's TLB array, establishing a shared memory area
  5634. between userspace and KVM. The "params" and "array" fields are userspace
  5635. addresses of mmu-type-specific data structures. The "array_len" field is an
  5636. safety mechanism, and should be set to the size in bytes of the memory that
  5637. userspace has reserved for the array. It must be at least the size dictated
  5638. by "mmu_type" and "params".
  5639. While KVM_RUN is active, the shared region is under control of KVM. Its
  5640. contents are undefined, and any modification by userspace results in
  5641. boundedly undefined behavior.
  5642. On return from KVM_RUN, the shared region will reflect the current state of
  5643. the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
  5644. to tell KVM which entries have been changed, prior to calling KVM_RUN again
  5645. on this vcpu.
  5646. For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
  5647. - The "params" field is of type "struct kvm_book3e_206_tlb_params".
  5648. - The "array" field points to an array of type "struct
  5649. kvm_book3e_206_tlb_entry".
  5650. - The array consists of all entries in the first TLB, followed by all
  5651. entries in the second TLB.
  5652. - Within a TLB, entries are ordered first by increasing set number. Within a
  5653. set, entries are ordered by way (increasing ESEL).
  5654. - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
  5655. where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
  5656. - The tsize field of mas1 shall be set to 4K on TLB0, even though the
  5657. hardware ignores this value for TLB0.
  5658. 6.4 KVM_CAP_S390_CSS_SUPPORT
  5659. ----------------------------
  5660. :Architectures: s390
  5661. :Target: vcpu
  5662. :Parameters: none
  5663. :Returns: 0 on success; -1 on error
  5664. This capability enables support for handling of channel I/O instructions.
  5665. TEST PENDING INTERRUPTION and the interrupt portion of TEST SUBCHANNEL are
  5666. handled in-kernel, while the other I/O instructions are passed to userspace.
  5667. When this capability is enabled, KVM_EXIT_S390_TSCH will occur on TEST
  5668. SUBCHANNEL intercepts.
  5669. Note that even though this capability is enabled per-vcpu, the complete
  5670. virtual machine is affected.
  5671. 6.5 KVM_CAP_PPC_EPR
  5672. -------------------
  5673. :Architectures: ppc
  5674. :Target: vcpu
  5675. :Parameters: args[0] defines whether the proxy facility is active
  5676. :Returns: 0 on success; -1 on error
  5677. This capability enables or disables the delivery of interrupts through the
  5678. external proxy facility.
  5679. When enabled (args[0] != 0), every time the guest gets an external interrupt
  5680. delivered, it automatically exits into user space with a KVM_EXIT_EPR exit
  5681. to receive the topmost interrupt vector.
  5682. When disabled (args[0] == 0), behavior is as if this facility is unsupported.
  5683. When this capability is enabled, KVM_EXIT_EPR can occur.
  5684. 6.6 KVM_CAP_IRQ_MPIC
  5685. --------------------
  5686. :Architectures: ppc
  5687. :Parameters: args[0] is the MPIC device fd;
  5688. args[1] is the MPIC CPU number for this vcpu
  5689. This capability connects the vcpu to an in-kernel MPIC device.
  5690. 6.7 KVM_CAP_IRQ_XICS
  5691. --------------------
  5692. :Architectures: ppc
  5693. :Target: vcpu
  5694. :Parameters: args[0] is the XICS device fd;
  5695. args[1] is the XICS CPU number (server ID) for this vcpu
  5696. This capability connects the vcpu to an in-kernel XICS device.
  5697. 6.8 KVM_CAP_S390_IRQCHIP
  5698. ------------------------
  5699. :Architectures: s390
  5700. :Target: vm
  5701. :Parameters: none
  5702. This capability enables the in-kernel irqchip for s390. Please refer to
  5703. "4.24 KVM_CREATE_IRQCHIP" for details.
  5704. 6.9 KVM_CAP_MIPS_FPU
  5705. --------------------
  5706. :Architectures: mips
  5707. :Target: vcpu
  5708. :Parameters: args[0] is reserved for future use (should be 0).
  5709. This capability allows the use of the host Floating Point Unit by the guest. It
  5710. allows the Config1.FP bit to be set to enable the FPU in the guest. Once this is
  5711. done the ``KVM_REG_MIPS_FPR_*`` and ``KVM_REG_MIPS_FCR_*`` registers can be
  5712. accessed (depending on the current guest FPU register mode), and the Status.FR,
  5713. Config5.FRE bits are accessible via the KVM API and also from the guest,
  5714. depending on them being supported by the FPU.
  5715. 6.10 KVM_CAP_MIPS_MSA
  5716. ---------------------
  5717. :Architectures: mips
  5718. :Target: vcpu
  5719. :Parameters: args[0] is reserved for future use (should be 0).
  5720. This capability allows the use of the MIPS SIMD Architecture (MSA) by the guest.
  5721. It allows the Config3.MSAP bit to be set to enable the use of MSA by the guest.
  5722. Once this is done the ``KVM_REG_MIPS_VEC_*`` and ``KVM_REG_MIPS_MSA_*``
  5723. registers can be accessed, and the Config5.MSAEn bit is accessible via the
  5724. KVM API and also from the guest.
  5725. 6.74 KVM_CAP_SYNC_REGS
  5726. ----------------------
  5727. :Architectures: s390, x86
  5728. :Target: s390: always enabled, x86: vcpu
  5729. :Parameters: none
  5730. :Returns: x86: KVM_CHECK_EXTENSION returns a bit-array indicating which register
  5731. sets are supported
  5732. (bitfields defined in arch/x86/include/uapi/asm/kvm.h).
  5733. As described above in the kvm_sync_regs struct info in section 5 (kvm_run):
  5734. KVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers
  5735. without having to call SET/GET_*REGS". This reduces overhead by eliminating
  5736. repeated ioctl calls for setting and/or getting register values. This is
  5737. particularly important when userspace is making synchronous guest state
  5738. modifications, e.g. when emulating and/or intercepting instructions in
  5739. userspace.
  5740. For s390 specifics, please refer to the source code.
  5741. For x86:
  5742. - the register sets to be copied out to kvm_run are selectable
  5743. by userspace (rather that all sets being copied out for every exit).
  5744. - vcpu_events are available in addition to regs and sregs.
  5745. For x86, the 'kvm_valid_regs' field of struct kvm_run is overloaded to
  5746. function as an input bit-array field set by userspace to indicate the
  5747. specific register sets to be copied out on the next exit.
  5748. To indicate when userspace has modified values that should be copied into
  5749. the vCPU, the all architecture bitarray field, 'kvm_dirty_regs' must be set.
  5750. This is done using the same bitflags as for the 'kvm_valid_regs' field.
  5751. If the dirty bit is not set, then the register set values will not be copied
  5752. into the vCPU even if they've been modified.
  5753. Unused bitfields in the bitarrays must be set to zero.
  5754. ::
  5755. struct kvm_sync_regs {
  5756. struct kvm_regs regs;
  5757. struct kvm_sregs sregs;
  5758. struct kvm_vcpu_events events;
  5759. };
  5760. 6.75 KVM_CAP_PPC_IRQ_XIVE
  5761. -------------------------
  5762. :Architectures: ppc
  5763. :Target: vcpu
  5764. :Parameters: args[0] is the XIVE device fd;
  5765. args[1] is the XIVE CPU number (server ID) for this vcpu
  5766. This capability connects the vcpu to an in-kernel XIVE device.
  5767. 7. Capabilities that can be enabled on VMs
  5768. ==========================================
  5769. There are certain capabilities that change the behavior of the virtual
  5770. machine when enabled. To enable them, please see section 4.37. Below
  5771. you can find a list of capabilities and what their effect on the VM
  5772. is when enabling them.
  5773. The following information is provided along with the description:
  5774. Architectures:
  5775. which instruction set architectures provide this ioctl.
  5776. x86 includes both i386 and x86_64.
  5777. Parameters:
  5778. what parameters are accepted by the capability.
  5779. Returns:
  5780. the return value. General error numbers (EBADF, ENOMEM, EINVAL)
  5781. are not detailed, but errors with specific meanings are.
  5782. 7.1 KVM_CAP_PPC_ENABLE_HCALL
  5783. ----------------------------
  5784. :Architectures: ppc
  5785. :Parameters: args[0] is the sPAPR hcall number;
  5786. args[1] is 0 to disable, 1 to enable in-kernel handling
  5787. This capability controls whether individual sPAPR hypercalls (hcalls)
  5788. get handled by the kernel or not. Enabling or disabling in-kernel
  5789. handling of an hcall is effective across the VM. On creation, an
  5790. initial set of hcalls are enabled for in-kernel handling, which
  5791. consists of those hcalls for which in-kernel handlers were implemented
  5792. before this capability was implemented. If disabled, the kernel will
  5793. not to attempt to handle the hcall, but will always exit to userspace
  5794. to handle it. Note that it may not make sense to enable some and
  5795. disable others of a group of related hcalls, but KVM does not prevent
  5796. userspace from doing that.
  5797. If the hcall number specified is not one that has an in-kernel
  5798. implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL
  5799. error.
  5800. 7.2 KVM_CAP_S390_USER_SIGP
  5801. --------------------------
  5802. :Architectures: s390
  5803. :Parameters: none
  5804. This capability controls which SIGP orders will be handled completely in user
  5805. space. With this capability enabled, all fast orders will be handled completely
  5806. in the kernel:
  5807. - SENSE
  5808. - SENSE RUNNING
  5809. - EXTERNAL CALL
  5810. - EMERGENCY SIGNAL
  5811. - CONDITIONAL EMERGENCY SIGNAL
  5812. All other orders will be handled completely in user space.
  5813. Only privileged operation exceptions will be checked for in the kernel (or even
  5814. in the hardware prior to interception). If this capability is not enabled, the
  5815. old way of handling SIGP orders is used (partially in kernel and user space).
  5816. 7.3 KVM_CAP_S390_VECTOR_REGISTERS
  5817. ---------------------------------
  5818. :Architectures: s390
  5819. :Parameters: none
  5820. :Returns: 0 on success, negative value on error
  5821. Allows use of the vector registers introduced with z13 processor, and
  5822. provides for the synchronization between host and user space. Will
  5823. return -EINVAL if the machine does not support vectors.
  5824. 7.4 KVM_CAP_S390_USER_STSI
  5825. --------------------------
  5826. :Architectures: s390
  5827. :Parameters: none
  5828. This capability allows post-handlers for the STSI instruction. After
  5829. initial handling in the kernel, KVM exits to user space with
  5830. KVM_EXIT_S390_STSI to allow user space to insert further data.
  5831. Before exiting to userspace, kvm handlers should fill in s390_stsi field of
  5832. vcpu->run::
  5833. struct {
  5834. __u64 addr;
  5835. __u8 ar;
  5836. __u8 reserved;
  5837. __u8 fc;
  5838. __u8 sel1;
  5839. __u16 sel2;
  5840. } s390_stsi;
  5841. @addr - guest address of STSI SYSIB
  5842. @fc - function code
  5843. @sel1 - selector 1
  5844. @sel2 - selector 2
  5845. @ar - access register number
  5846. KVM handlers should exit to userspace with rc = -EREMOTE.
  5847. 7.5 KVM_CAP_SPLIT_IRQCHIP
  5848. -------------------------
  5849. :Architectures: x86
  5850. :Parameters: args[0] - number of routes reserved for userspace IOAPICs
  5851. :Returns: 0 on success, -1 on error
  5852. Create a local apic for each processor in the kernel. This can be used
  5853. instead of KVM_CREATE_IRQCHIP if the userspace VMM wishes to emulate the
  5854. IOAPIC and PIC (and also the PIT, even though this has to be enabled
  5855. separately).
  5856. This capability also enables in kernel routing of interrupt requests;
  5857. when KVM_CAP_SPLIT_IRQCHIP only routes of KVM_IRQ_ROUTING_MSI type are
  5858. used in the IRQ routing table. The first args[0] MSI routes are reserved
  5859. for the IOAPIC pins. Whenever the LAPIC receives an EOI for these routes,
  5860. a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace.
  5861. Fails if VCPU has already been created, or if the irqchip is already in the
  5862. kernel (i.e. KVM_CREATE_IRQCHIP has already been called).
  5863. 7.6 KVM_CAP_S390_RI
  5864. -------------------
  5865. :Architectures: s390
  5866. :Parameters: none
  5867. Allows use of runtime-instrumentation introduced with zEC12 processor.
  5868. Will return -EINVAL if the machine does not support runtime-instrumentation.
  5869. Will return -EBUSY if a VCPU has already been created.
  5870. 7.7 KVM_CAP_X2APIC_API
  5871. ----------------------
  5872. :Architectures: x86
  5873. :Parameters: args[0] - features that should be enabled
  5874. :Returns: 0 on success, -EINVAL when args[0] contains invalid features
  5875. Valid feature flags in args[0] are::
  5876. #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
  5877. #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
  5878. Enabling KVM_X2APIC_API_USE_32BIT_IDS changes the behavior of
  5879. KVM_SET_GSI_ROUTING, KVM_SIGNAL_MSI, KVM_SET_LAPIC, and KVM_GET_LAPIC,
  5880. allowing the use of 32-bit APIC IDs. See KVM_CAP_X2APIC_API in their
  5881. respective sections.
  5882. KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK must be enabled for x2APIC to work
  5883. in logical mode or with more than 255 VCPUs. Otherwise, KVM treats 0xff
  5884. as a broadcast even in x2APIC mode in order to support physical x2APIC
  5885. without interrupt remapping. This is undesirable in logical mode,
  5886. where 0xff represents CPUs 0-7 in cluster 0.
  5887. 7.8 KVM_CAP_S390_USER_INSTR0
  5888. ----------------------------
  5889. :Architectures: s390
  5890. :Parameters: none
  5891. With this capability enabled, all illegal instructions 0x0000 (2 bytes) will
  5892. be intercepted and forwarded to user space. User space can use this
  5893. mechanism e.g. to realize 2-byte software breakpoints. The kernel will
  5894. not inject an operating exception for these instructions, user space has
  5895. to take care of that.
  5896. This capability can be enabled dynamically even if VCPUs were already
  5897. created and are running.
  5898. 7.9 KVM_CAP_S390_GS
  5899. -------------------
  5900. :Architectures: s390
  5901. :Parameters: none
  5902. :Returns: 0 on success; -EINVAL if the machine does not support
  5903. guarded storage; -EBUSY if a VCPU has already been created.
  5904. Allows use of guarded storage for the KVM guest.
  5905. 7.10 KVM_CAP_S390_AIS
  5906. ---------------------
  5907. :Architectures: s390
  5908. :Parameters: none
  5909. Allow use of adapter-interruption suppression.
  5910. :Returns: 0 on success; -EBUSY if a VCPU has already been created.
  5911. 7.11 KVM_CAP_PPC_SMT
  5912. --------------------
  5913. :Architectures: ppc
  5914. :Parameters: vsmt_mode, flags
  5915. Enabling this capability on a VM provides userspace with a way to set
  5916. the desired virtual SMT mode (i.e. the number of virtual CPUs per
  5917. virtual core). The virtual SMT mode, vsmt_mode, must be a power of 2
  5918. between 1 and 8. On POWER8, vsmt_mode must also be no greater than
  5919. the number of threads per subcore for the host. Currently flags must
  5920. be 0. A successful call to enable this capability will result in
  5921. vsmt_mode being returned when the KVM_CAP_PPC_SMT capability is
  5922. subsequently queried for the VM. This capability is only supported by
  5923. HV KVM, and can only be set before any VCPUs have been created.
  5924. The KVM_CAP_PPC_SMT_POSSIBLE capability indicates which virtual SMT
  5925. modes are available.
  5926. 7.12 KVM_CAP_PPC_FWNMI
  5927. ----------------------
  5928. :Architectures: ppc
  5929. :Parameters: none
  5930. With this capability a machine check exception in the guest address
  5931. space will cause KVM to exit the guest with NMI exit reason. This
  5932. enables QEMU to build error log and branch to guest kernel registered
  5933. machine check handling routine. Without this capability KVM will
  5934. branch to guests' 0x200 interrupt vector.
  5935. 7.13 KVM_CAP_X86_DISABLE_EXITS
  5936. ------------------------------
  5937. :Architectures: x86
  5938. :Parameters: args[0] defines which exits are disabled
  5939. :Returns: 0 on success, -EINVAL when args[0] contains invalid exits
  5940. Valid bits in args[0] are::
  5941. #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
  5942. #define KVM_X86_DISABLE_EXITS_HLT (1 << 1)
  5943. #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2)
  5944. #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3)
  5945. Enabling this capability on a VM provides userspace with a way to no
  5946. longer intercept some instructions for improved latency in some
  5947. workloads, and is suggested when vCPUs are associated to dedicated
  5948. physical CPUs. More bits can be added in the future; userspace can
  5949. just pass the KVM_CHECK_EXTENSION result to KVM_ENABLE_CAP to disable
  5950. all such vmexits.
  5951. Do not enable KVM_FEATURE_PV_UNHALT if you disable HLT exits.
  5952. 7.14 KVM_CAP_S390_HPAGE_1M
  5953. --------------------------
  5954. :Architectures: s390
  5955. :Parameters: none
  5956. :Returns: 0 on success, -EINVAL if hpage module parameter was not set
  5957. or cmma is enabled, or the VM has the KVM_VM_S390_UCONTROL
  5958. flag set
  5959. With this capability the KVM support for memory backing with 1m pages
  5960. through hugetlbfs can be enabled for a VM. After the capability is
  5961. enabled, cmma can't be enabled anymore and pfmfi and the storage key
  5962. interpretation are disabled. If cmma has already been enabled or the
  5963. hpage module parameter is not set to 1, -EINVAL is returned.
  5964. While it is generally possible to create a huge page backed VM without
  5965. this capability, the VM will not be able to run.
  5966. 7.15 KVM_CAP_MSR_PLATFORM_INFO
  5967. ------------------------------
  5968. :Architectures: x86
  5969. :Parameters: args[0] whether feature should be enabled or not
  5970. With this capability, a guest may read the MSR_PLATFORM_INFO MSR. Otherwise,
  5971. a #GP would be raised when the guest tries to access. Currently, this
  5972. capability does not enable write permissions of this MSR for the guest.
  5973. 7.16 KVM_CAP_PPC_NESTED_HV
  5974. --------------------------
  5975. :Architectures: ppc
  5976. :Parameters: none
  5977. :Returns: 0 on success, -EINVAL when the implementation doesn't support
  5978. nested-HV virtualization.
  5979. HV-KVM on POWER9 and later systems allows for "nested-HV"
  5980. virtualization, which provides a way for a guest VM to run guests that
  5981. can run using the CPU's supervisor mode (privileged non-hypervisor
  5982. state). Enabling this capability on a VM depends on the CPU having
  5983. the necessary functionality and on the facility being enabled with a
  5984. kvm-hv module parameter.
  5985. 7.17 KVM_CAP_EXCEPTION_PAYLOAD
  5986. ------------------------------
  5987. :Architectures: x86
  5988. :Parameters: args[0] whether feature should be enabled or not
  5989. With this capability enabled, CR2 will not be modified prior to the
  5990. emulated VM-exit when L1 intercepts a #PF exception that occurs in
  5991. L2. Similarly, for kvm-intel only, DR6 will not be modified prior to
  5992. the emulated VM-exit when L1 intercepts a #DB exception that occurs in
  5993. L2. As a result, when KVM_GET_VCPU_EVENTS reports a pending #PF (or
  5994. #DB) exception for L2, exception.has_payload will be set and the
  5995. faulting address (or the new DR6 bits*) will be reported in the
  5996. exception_payload field. Similarly, when userspace injects a #PF (or
  5997. #DB) into L2 using KVM_SET_VCPU_EVENTS, it is expected to set
  5998. exception.has_payload and to put the faulting address - or the new DR6
  5999. bits\ [#]_ - in the exception_payload field.
  6000. This capability also enables exception.pending in struct
  6001. kvm_vcpu_events, which allows userspace to distinguish between pending
  6002. and injected exceptions.
  6003. .. [#] For the new DR6 bits, note that bit 16 is set iff the #DB exception
  6004. will clear DR6.RTM.
  6005. 7.18 KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
  6006. --------------------------------------
  6007. :Architectures: x86, arm64, mips
  6008. :Parameters: args[0] whether feature should be enabled or not
  6009. Valid flags are::
  6010. #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
  6011. #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
  6012. With KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE is set, KVM_GET_DIRTY_LOG will not
  6013. automatically clear and write-protect all pages that are returned as dirty.
  6014. Rather, userspace will have to do this operation separately using
  6015. KVM_CLEAR_DIRTY_LOG.
  6016. At the cost of a slightly more complicated operation, this provides better
  6017. scalability and responsiveness for two reasons. First,
  6018. KVM_CLEAR_DIRTY_LOG ioctl can operate on a 64-page granularity rather
  6019. than requiring to sync a full memslot; this ensures that KVM does not
  6020. take spinlocks for an extended period of time. Second, in some cases a
  6021. large amount of time can pass between a call to KVM_GET_DIRTY_LOG and
  6022. userspace actually using the data in the page. Pages can be modified
  6023. during this time, which is inefficient for both the guest and userspace:
  6024. the guest will incur a higher penalty due to write protection faults,
  6025. while userspace can see false reports of dirty pages. Manual reprotection
  6026. helps reducing this time, improving guest performance and reducing the
  6027. number of dirty log false positives.
  6028. With KVM_DIRTY_LOG_INITIALLY_SET set, all the bits of the dirty bitmap
  6029. will be initialized to 1 when created. This also improves performance because
  6030. dirty logging can be enabled gradually in small chunks on the first call
  6031. to KVM_CLEAR_DIRTY_LOG. KVM_DIRTY_LOG_INITIALLY_SET depends on
  6032. KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (it is also only available on
  6033. x86 and arm64 for now).
  6034. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 was previously available under the name
  6035. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT, but the implementation had bugs that make
  6036. it hard or impossible to use it correctly. The availability of
  6037. KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 signals that those bugs are fixed.
  6038. Userspace should not try to use KVM_CAP_MANUAL_DIRTY_LOG_PROTECT.
  6039. 7.19 KVM_CAP_PPC_SECURE_GUEST
  6040. ------------------------------
  6041. :Architectures: ppc
  6042. This capability indicates that KVM is running on a host that has
  6043. ultravisor firmware and thus can support a secure guest. On such a
  6044. system, a guest can ask the ultravisor to make it a secure guest,
  6045. one whose memory is inaccessible to the host except for pages which
  6046. are explicitly requested to be shared with the host. The ultravisor
  6047. notifies KVM when a guest requests to become a secure guest, and KVM
  6048. has the opportunity to veto the transition.
  6049. If present, this capability can be enabled for a VM, meaning that KVM
  6050. will allow the transition to secure guest mode. Otherwise KVM will
  6051. veto the transition.
  6052. 7.20 KVM_CAP_HALT_POLL
  6053. ----------------------
  6054. :Architectures: all
  6055. :Target: VM
  6056. :Parameters: args[0] is the maximum poll time in nanoseconds
  6057. :Returns: 0 on success; -1 on error
  6058. KVM_CAP_HALT_POLL overrides the kvm.halt_poll_ns module parameter to set the
  6059. maximum halt-polling time for all vCPUs in the target VM. This capability can
  6060. be invoked at any time and any number of times to dynamically change the
  6061. maximum halt-polling time.
  6062. See Documentation/virt/kvm/halt-polling.rst for more information on halt
  6063. polling.
  6064. 7.21 KVM_CAP_X86_USER_SPACE_MSR
  6065. -------------------------------
  6066. :Architectures: x86
  6067. :Target: VM
  6068. :Parameters: args[0] contains the mask of KVM_MSR_EXIT_REASON_* events to report
  6069. :Returns: 0 on success; -1 on error
  6070. This capability allows userspace to intercept RDMSR and WRMSR instructions if
  6071. access to an MSR is denied. By default, KVM injects #GP on denied accesses.
  6072. When a guest requests to read or write an MSR, KVM may not implement all MSRs
  6073. that are relevant to a respective system. It also does not differentiate by
  6074. CPU type.
  6075. To allow more fine grained control over MSR handling, userspace may enable
  6076. this capability. With it enabled, MSR accesses that match the mask specified in
  6077. args[0] and would trigger a #GP inside the guest will instead trigger
  6078. KVM_EXIT_X86_RDMSR and KVM_EXIT_X86_WRMSR exit notifications. Userspace
  6079. can then implement model specific MSR handling and/or user notifications
  6080. to inform a user that an MSR was not emulated/virtualized by KVM.
  6081. The valid mask flags are:
  6082. ============================ ===============================================
  6083. KVM_MSR_EXIT_REASON_UNKNOWN intercept accesses to unknown (to KVM) MSRs
  6084. KVM_MSR_EXIT_REASON_INVAL intercept accesses that are architecturally
  6085. invalid according to the vCPU model and/or mode
  6086. KVM_MSR_EXIT_REASON_FILTER intercept accesses that are denied by userspace
  6087. via KVM_X86_SET_MSR_FILTER
  6088. ============================ ===============================================
  6089. 7.22 KVM_CAP_X86_BUS_LOCK_EXIT
  6090. -------------------------------
  6091. :Architectures: x86
  6092. :Target: VM
  6093. :Parameters: args[0] defines the policy used when bus locks detected in guest
  6094. :Returns: 0 on success, -EINVAL when args[0] contains invalid bits
  6095. Valid bits in args[0] are::
  6096. #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
  6097. #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
  6098. Enabling this capability on a VM provides userspace with a way to select a
  6099. policy to handle the bus locks detected in guest. Userspace can obtain the
  6100. supported modes from the result of KVM_CHECK_EXTENSION and define it through
  6101. the KVM_ENABLE_CAP. The supported modes are mutually-exclusive.
  6102. This capability allows userspace to force VM exits on bus locks detected in the
  6103. guest, irrespective whether or not the host has enabled split-lock detection
  6104. (which triggers an #AC exception that KVM intercepts). This capability is
  6105. intended to mitigate attacks where a malicious/buggy guest can exploit bus
  6106. locks to degrade the performance of the whole system.
  6107. If KVM_BUS_LOCK_DETECTION_OFF is set, KVM doesn't force guest bus locks to VM
  6108. exit, although the host kernel's split-lock #AC detection still applies, if
  6109. enabled.
  6110. If KVM_BUS_LOCK_DETECTION_EXIT is set, KVM enables a CPU feature that ensures
  6111. bus locks in the guest trigger a VM exit, and KVM exits to userspace for all
  6112. such VM exits, e.g. to allow userspace to throttle the offending guest and/or
  6113. apply some other policy-based mitigation. When exiting to userspace, KVM sets
  6114. KVM_RUN_X86_BUS_LOCK in vcpu-run->flags, and conditionally sets the exit_reason
  6115. to KVM_EXIT_X86_BUS_LOCK.
  6116. Note! Detected bus locks may be coincident with other exits to userspace, i.e.
  6117. KVM_RUN_X86_BUS_LOCK should be checked regardless of the primary exit reason if
  6118. userspace wants to take action on all detected bus locks.
  6119. 7.23 KVM_CAP_PPC_DAWR1
  6120. ----------------------
  6121. :Architectures: ppc
  6122. :Parameters: none
  6123. :Returns: 0 on success, -EINVAL when CPU doesn't support 2nd DAWR
  6124. This capability can be used to check / enable 2nd DAWR feature provided
  6125. by POWER10 processor.
  6126. 7.24 KVM_CAP_VM_COPY_ENC_CONTEXT_FROM
  6127. -------------------------------------
  6128. Architectures: x86 SEV enabled
  6129. Type: vm
  6130. Parameters: args[0] is the fd of the source vm
  6131. Returns: 0 on success; ENOTTY on error
  6132. This capability enables userspace to copy encryption context from the vm
  6133. indicated by the fd to the vm this is called on.
  6134. This is intended to support in-guest workloads scheduled by the host. This
  6135. allows the in-guest workload to maintain its own NPTs and keeps the two vms
  6136. from accidentally clobbering each other with interrupts and the like (separate
  6137. APIC/MSRs/etc).
  6138. 7.25 KVM_CAP_SGX_ATTRIBUTE
  6139. --------------------------
  6140. :Architectures: x86
  6141. :Target: VM
  6142. :Parameters: args[0] is a file handle of a SGX attribute file in securityfs
  6143. :Returns: 0 on success, -EINVAL if the file handle is invalid or if a requested
  6144. attribute is not supported by KVM.
  6145. KVM_CAP_SGX_ATTRIBUTE enables a userspace VMM to grant a VM access to one or
  6146. more privileged enclave attributes. args[0] must hold a file handle to a valid
  6147. SGX attribute file corresponding to an attribute that is supported/restricted
  6148. by KVM (currently only PROVISIONKEY).
  6149. The SGX subsystem restricts access to a subset of enclave attributes to provide
  6150. additional security for an uncompromised kernel, e.g. use of the PROVISIONKEY
  6151. is restricted to deter malware from using the PROVISIONKEY to obtain a stable
  6152. system fingerprint. To prevent userspace from circumventing such restrictions
  6153. by running an enclave in a VM, KVM prevents access to privileged attributes by
  6154. default.
  6155. See Documentation/arch/x86/sgx.rst for more details.
  6156. 7.26 KVM_CAP_PPC_RPT_INVALIDATE
  6157. -------------------------------
  6158. :Capability: KVM_CAP_PPC_RPT_INVALIDATE
  6159. :Architectures: ppc
  6160. :Type: vm
  6161. This capability indicates that the kernel is capable of handling
  6162. H_RPT_INVALIDATE hcall.
  6163. In order to enable the use of H_RPT_INVALIDATE in the guest,
  6164. user space might have to advertise it for the guest. For example,
  6165. IBM pSeries (sPAPR) guest starts using it if "hcall-rpt-invalidate" is
  6166. present in the "ibm,hypertas-functions" device-tree property.
  6167. This capability is enabled for hypervisors on platforms like POWER9
  6168. that support radix MMU.
  6169. 7.27 KVM_CAP_EXIT_ON_EMULATION_FAILURE
  6170. --------------------------------------
  6171. :Architectures: x86
  6172. :Parameters: args[0] whether the feature should be enabled or not
  6173. When this capability is enabled, an emulation failure will result in an exit
  6174. to userspace with KVM_INTERNAL_ERROR (except when the emulator was invoked
  6175. to handle a VMware backdoor instruction). Furthermore, KVM will now provide up
  6176. to 15 instruction bytes for any exit to userspace resulting from an emulation
  6177. failure. When these exits to userspace occur use the emulation_failure struct
  6178. instead of the internal struct. They both have the same layout, but the
  6179. emulation_failure struct matches the content better. It also explicitly
  6180. defines the 'flags' field which is used to describe the fields in the struct
  6181. that are valid (ie: if KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES is
  6182. set in the 'flags' field then both 'insn_size' and 'insn_bytes' have valid data
  6183. in them.)
  6184. 7.28 KVM_CAP_ARM_MTE
  6185. --------------------
  6186. :Architectures: arm64
  6187. :Parameters: none
  6188. This capability indicates that KVM (and the hardware) supports exposing the
  6189. Memory Tagging Extensions (MTE) to the guest. It must also be enabled by the
  6190. VMM before creating any VCPUs to allow the guest access. Note that MTE is only
  6191. available to a guest running in AArch64 mode and enabling this capability will
  6192. cause attempts to create AArch32 VCPUs to fail.
  6193. When enabled the guest is able to access tags associated with any memory given
  6194. to the guest. KVM will ensure that the tags are maintained during swap or
  6195. hibernation of the host; however the VMM needs to manually save/restore the
  6196. tags as appropriate if the VM is migrated.
  6197. When this capability is enabled all memory in memslots must be mapped as
  6198. ``MAP_ANONYMOUS`` or with a RAM-based file mapping (``tmpfs``, ``memfd``),
  6199. attempts to create a memslot with an invalid mmap will result in an
  6200. -EINVAL return.
  6201. When enabled the VMM may make use of the ``KVM_ARM_MTE_COPY_TAGS`` ioctl to
  6202. perform a bulk copy of tags to/from the guest.
  6203. 7.29 KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM
  6204. -------------------------------------
  6205. :Architectures: x86 SEV enabled
  6206. :Type: vm
  6207. :Parameters: args[0] is the fd of the source vm
  6208. :Returns: 0 on success
  6209. This capability enables userspace to migrate the encryption context from the VM
  6210. indicated by the fd to the VM this is called on.
  6211. This is intended to support intra-host migration of VMs between userspace VMMs,
  6212. upgrading the VMM process without interrupting the guest.
  6213. 7.30 KVM_CAP_PPC_AIL_MODE_3
  6214. -------------------------------
  6215. :Capability: KVM_CAP_PPC_AIL_MODE_3
  6216. :Architectures: ppc
  6217. :Type: vm
  6218. This capability indicates that the kernel supports the mode 3 setting for the
  6219. "Address Translation Mode on Interrupt" aka "Alternate Interrupt Location"
  6220. resource that is controlled with the H_SET_MODE hypercall.
  6221. This capability allows a guest kernel to use a better-performance mode for
  6222. handling interrupts and system calls.
  6223. 7.31 KVM_CAP_DISABLE_QUIRKS2
  6224. ----------------------------
  6225. :Capability: KVM_CAP_DISABLE_QUIRKS2
  6226. :Parameters: args[0] - set of KVM quirks to disable
  6227. :Architectures: x86
  6228. :Type: vm
  6229. This capability, if enabled, will cause KVM to disable some behavior
  6230. quirks.
  6231. Calling KVM_CHECK_EXTENSION for this capability returns a bitmask of
  6232. quirks that can be disabled in KVM.
  6233. The argument to KVM_ENABLE_CAP for this capability is a bitmask of
  6234. quirks to disable, and must be a subset of the bitmask returned by
  6235. KVM_CHECK_EXTENSION.
  6236. The valid bits in cap.args[0] are:
  6237. =================================== ============================================
  6238. KVM_X86_QUIRK_LINT0_REENABLED By default, the reset value for the LVT
  6239. LINT0 register is 0x700 (APIC_MODE_EXTINT).
  6240. When this quirk is disabled, the reset value
  6241. is 0x10000 (APIC_LVT_MASKED).
  6242. KVM_X86_QUIRK_CD_NW_CLEARED By default, KVM clears CR0.CD and CR0.NW on
  6243. AMD CPUs to workaround buggy guest firmware
  6244. that runs in perpetuity with CR0.CD, i.e.
  6245. with caches in "no fill" mode.
  6246. When this quirk is disabled, KVM does not
  6247. change the value of CR0.CD and CR0.NW.
  6248. KVM_X86_QUIRK_LAPIC_MMIO_HOLE By default, the MMIO LAPIC interface is
  6249. available even when configured for x2APIC
  6250. mode. When this quirk is disabled, KVM
  6251. disables the MMIO LAPIC interface if the
  6252. LAPIC is in x2APIC mode.
  6253. KVM_X86_QUIRK_OUT_7E_INC_RIP By default, KVM pre-increments %rip before
  6254. exiting to userspace for an OUT instruction
  6255. to port 0x7e. When this quirk is disabled,
  6256. KVM does not pre-increment %rip before
  6257. exiting to userspace.
  6258. KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT When this quirk is disabled, KVM sets
  6259. CPUID.01H:ECX[bit 3] (MONITOR/MWAIT) if
  6260. IA32_MISC_ENABLE[bit 18] (MWAIT) is set.
  6261. Additionally, when this quirk is disabled,
  6262. KVM clears CPUID.01H:ECX[bit 3] if
  6263. IA32_MISC_ENABLE[bit 18] is cleared.
  6264. KVM_X86_QUIRK_FIX_HYPERCALL_INSN By default, KVM rewrites guest
  6265. VMMCALL/VMCALL instructions to match the
  6266. vendor's hypercall instruction for the
  6267. system. When this quirk is disabled, KVM
  6268. will no longer rewrite invalid guest
  6269. hypercall instructions. Executing the
  6270. incorrect hypercall instruction will
  6271. generate a #UD within the guest.
  6272. KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS By default, KVM emulates MONITOR/MWAIT (if
  6273. they are intercepted) as NOPs regardless of
  6274. whether or not MONITOR/MWAIT are supported
  6275. according to guest CPUID. When this quirk
  6276. is disabled and KVM_X86_DISABLE_EXITS_MWAIT
  6277. is not set (MONITOR/MWAIT are intercepted),
  6278. KVM will inject a #UD on MONITOR/MWAIT if
  6279. they're unsupported per guest CPUID. Note,
  6280. KVM will modify MONITOR/MWAIT support in
  6281. guest CPUID on writes to MISC_ENABLE if
  6282. KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT is
  6283. disabled.
  6284. KVM_X86_QUIRK_SLOT_ZAP_ALL By default, for KVM_X86_DEFAULT_VM VMs, KVM
  6285. invalidates all SPTEs in all memslots and
  6286. address spaces when a memslot is deleted or
  6287. moved. When this quirk is disabled (or the
  6288. VM type isn't KVM_X86_DEFAULT_VM), KVM only
  6289. ensures the backing memory of the deleted
  6290. or moved memslot isn't reachable, i.e KVM
  6291. _may_ invalidate only SPTEs related to the
  6292. memslot.
  6293. =================================== ============================================
  6294. 7.32 KVM_CAP_MAX_VCPU_ID
  6295. ------------------------
  6296. :Architectures: x86
  6297. :Target: VM
  6298. :Parameters: args[0] - maximum APIC ID value set for current VM
  6299. :Returns: 0 on success, -EINVAL if args[0] is beyond KVM_MAX_VCPU_IDS
  6300. supported in KVM or if it has been set.
  6301. This capability allows userspace to specify maximum possible APIC ID
  6302. assigned for current VM session prior to the creation of vCPUs, saving
  6303. memory for data structures indexed by the APIC ID. Userspace is able
  6304. to calculate the limit to APIC ID values from designated
  6305. CPU topology.
  6306. The value can be changed only until KVM_ENABLE_CAP is set to a nonzero
  6307. value or until a vCPU is created. Upon creation of the first vCPU,
  6308. if the value was set to zero or KVM_ENABLE_CAP was not invoked, KVM
  6309. uses the return value of KVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPU_ID) as
  6310. the maximum APIC ID.
  6311. 7.33 KVM_CAP_X86_NOTIFY_VMEXIT
  6312. ------------------------------
  6313. :Architectures: x86
  6314. :Target: VM
  6315. :Parameters: args[0] is the value of notify window as well as some flags
  6316. :Returns: 0 on success, -EINVAL if args[0] contains invalid flags or notify
  6317. VM exit is unsupported.
  6318. Bits 63:32 of args[0] are used for notify window.
  6319. Bits 31:0 of args[0] are for some flags. Valid bits are::
  6320. #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1 << 0)
  6321. #define KVM_X86_NOTIFY_VMEXIT_USER (1 << 1)
  6322. This capability allows userspace to configure the notify VM exit on/off
  6323. in per-VM scope during VM creation. Notify VM exit is disabled by default.
  6324. When userspace sets KVM_X86_NOTIFY_VMEXIT_ENABLED bit in args[0], VMM will
  6325. enable this feature with the notify window provided, which will generate
  6326. a VM exit if no event window occurs in VM non-root mode for a specified of
  6327. time (notify window).
  6328. If KVM_X86_NOTIFY_VMEXIT_USER is set in args[0], upon notify VM exits happen,
  6329. KVM would exit to userspace for handling.
  6330. This capability is aimed to mitigate the threat that malicious VMs can
  6331. cause CPU stuck (due to event windows don't open up) and make the CPU
  6332. unavailable to host or other VMs.
  6333. 7.34 KVM_CAP_MEMORY_FAULT_INFO
  6334. ------------------------------
  6335. :Architectures: x86
  6336. :Returns: Informational only, -EINVAL on direct KVM_ENABLE_CAP.
  6337. The presence of this capability indicates that KVM_RUN will fill
  6338. kvm_run.memory_fault if KVM cannot resolve a guest page fault VM-Exit, e.g. if
  6339. there is a valid memslot but no backing VMA for the corresponding host virtual
  6340. address.
  6341. The information in kvm_run.memory_fault is valid if and only if KVM_RUN returns
  6342. an error with errno=EFAULT or errno=EHWPOISON *and* kvm_run.exit_reason is set
  6343. to KVM_EXIT_MEMORY_FAULT.
  6344. Note: Userspaces which attempt to resolve memory faults so that they can retry
  6345. KVM_RUN are encouraged to guard against repeatedly receiving the same
  6346. error/annotated fault.
  6347. See KVM_EXIT_MEMORY_FAULT for more information.
  6348. 7.35 KVM_CAP_X86_APIC_BUS_CYCLES_NS
  6349. -----------------------------------
  6350. :Architectures: x86
  6351. :Target: VM
  6352. :Parameters: args[0] is the desired APIC bus clock rate, in nanoseconds
  6353. :Returns: 0 on success, -EINVAL if args[0] contains an invalid value for the
  6354. frequency or if any vCPUs have been created, -ENXIO if a virtual
  6355. local APIC has not been created using KVM_CREATE_IRQCHIP.
  6356. This capability sets the VM's APIC bus clock frequency, used by KVM's in-kernel
  6357. virtual APIC when emulating APIC timers. KVM's default value can be retrieved
  6358. by KVM_CHECK_EXTENSION.
  6359. Note: Userspace is responsible for correctly configuring CPUID 0x15, a.k.a. the
  6360. core crystal clock frequency, if a non-zero CPUID 0x15 is exposed to the guest.
  6361. 7.36 KVM_CAP_X86_GUEST_MODE
  6362. ------------------------------
  6363. :Architectures: x86
  6364. :Returns: Informational only, -EINVAL on direct KVM_ENABLE_CAP.
  6365. The presence of this capability indicates that KVM_RUN will update the
  6366. KVM_RUN_X86_GUEST_MODE bit in kvm_run.flags to indicate whether the
  6367. vCPU was executing nested guest code when it exited.
  6368. KVM exits with the register state of either the L1 or L2 guest
  6369. depending on which executed at the time of an exit. Userspace must
  6370. take care to differentiate between these cases.
  6371. 8. Other capabilities.
  6372. ======================
  6373. This section lists capabilities that give information about other
  6374. features of the KVM implementation.
  6375. 8.1 KVM_CAP_PPC_HWRNG
  6376. ---------------------
  6377. :Architectures: ppc
  6378. This capability, if KVM_CHECK_EXTENSION indicates that it is
  6379. available, means that the kernel has an implementation of the
  6380. H_RANDOM hypercall backed by a hardware random-number generator.
  6381. If present, the kernel H_RANDOM handler can be enabled for guest use
  6382. with the KVM_CAP_PPC_ENABLE_HCALL capability.
  6383. 8.2 KVM_CAP_HYPERV_SYNIC
  6384. ------------------------
  6385. :Architectures: x86
  6386. This capability, if KVM_CHECK_EXTENSION indicates that it is
  6387. available, means that the kernel has an implementation of the
  6388. Hyper-V Synthetic interrupt controller(SynIC). Hyper-V SynIC is
  6389. used to support Windows Hyper-V based guest paravirt drivers(VMBus).
  6390. In order to use SynIC, it has to be activated by setting this
  6391. capability via KVM_ENABLE_CAP ioctl on the vcpu fd. Note that this
  6392. will disable the use of APIC hardware virtualization even if supported
  6393. by the CPU, as it's incompatible with SynIC auto-EOI behavior.
  6394. 8.3 KVM_CAP_PPC_MMU_RADIX
  6395. -------------------------
  6396. :Architectures: ppc
  6397. This capability, if KVM_CHECK_EXTENSION indicates that it is
  6398. available, means that the kernel can support guests using the
  6399. radix MMU defined in Power ISA V3.00 (as implemented in the POWER9
  6400. processor).
  6401. 8.4 KVM_CAP_PPC_MMU_HASH_V3
  6402. ---------------------------
  6403. :Architectures: ppc
  6404. This capability, if KVM_CHECK_EXTENSION indicates that it is
  6405. available, means that the kernel can support guests using the
  6406. hashed page table MMU defined in Power ISA V3.00 (as implemented in
  6407. the POWER9 processor), including in-memory segment tables.
  6408. 8.5 KVM_CAP_MIPS_VZ
  6409. -------------------
  6410. :Architectures: mips
  6411. This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
  6412. it is available, means that full hardware assisted virtualization capabilities
  6413. of the hardware are available for use through KVM. An appropriate
  6414. KVM_VM_MIPS_* type must be passed to KVM_CREATE_VM to create a VM which
  6415. utilises it.
  6416. If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
  6417. available, it means that the VM is using full hardware assisted virtualization
  6418. capabilities of the hardware. This is useful to check after creating a VM with
  6419. KVM_VM_MIPS_DEFAULT.
  6420. The value returned by KVM_CHECK_EXTENSION should be compared against known
  6421. values (see below). All other values are reserved. This is to allow for the
  6422. possibility of other hardware assisted virtualization implementations which
  6423. may be incompatible with the MIPS VZ ASE.
  6424. == ==========================================================================
  6425. 0 The trap & emulate implementation is in use to run guest code in user
  6426. mode. Guest virtual memory segments are rearranged to fit the guest in the
  6427. user mode address space.
  6428. 1 The MIPS VZ ASE is in use, providing full hardware assisted
  6429. virtualization, including standard guest virtual memory segments.
  6430. == ==========================================================================
  6431. 8.6 KVM_CAP_MIPS_TE
  6432. -------------------
  6433. :Architectures: mips
  6434. This capability, if KVM_CHECK_EXTENSION on the main kvm handle indicates that
  6435. it is available, means that the trap & emulate implementation is available to
  6436. run guest code in user mode, even if KVM_CAP_MIPS_VZ indicates that hardware
  6437. assisted virtualisation is also available. KVM_VM_MIPS_TE (0) must be passed
  6438. to KVM_CREATE_VM to create a VM which utilises it.
  6439. If KVM_CHECK_EXTENSION on a kvm VM handle indicates that this capability is
  6440. available, it means that the VM is using trap & emulate.
  6441. 8.7 KVM_CAP_MIPS_64BIT
  6442. ----------------------
  6443. :Architectures: mips
  6444. This capability indicates the supported architecture type of the guest, i.e. the
  6445. supported register and address width.
  6446. The values returned when this capability is checked by KVM_CHECK_EXTENSION on a
  6447. kvm VM handle correspond roughly to the CP0_Config.AT register field, and should
  6448. be checked specifically against known values (see below). All other values are
  6449. reserved.
  6450. == ========================================================================
  6451. 0 MIPS32 or microMIPS32.
  6452. Both registers and addresses are 32-bits wide.
  6453. It will only be possible to run 32-bit guest code.
  6454. 1 MIPS64 or microMIPS64 with access only to 32-bit compatibility segments.
  6455. Registers are 64-bits wide, but addresses are 32-bits wide.
  6456. 64-bit guest code may run but cannot access MIPS64 memory segments.
  6457. It will also be possible to run 32-bit guest code.
  6458. 2 MIPS64 or microMIPS64 with access to all address segments.
  6459. Both registers and addresses are 64-bits wide.
  6460. It will be possible to run 64-bit or 32-bit guest code.
  6461. == ========================================================================
  6462. 8.9 KVM_CAP_ARM_USER_IRQ
  6463. ------------------------
  6464. :Architectures: arm64
  6465. This capability, if KVM_CHECK_EXTENSION indicates that it is available, means
  6466. that if userspace creates a VM without an in-kernel interrupt controller, it
  6467. will be notified of changes to the output level of in-kernel emulated devices,
  6468. which can generate virtual interrupts, presented to the VM.
  6469. For such VMs, on every return to userspace, the kernel
  6470. updates the vcpu's run->s.regs.device_irq_level field to represent the actual
  6471. output level of the device.
  6472. Whenever kvm detects a change in the device output level, kvm guarantees at
  6473. least one return to userspace before running the VM. This exit could either
  6474. be a KVM_EXIT_INTR or any other exit event, like KVM_EXIT_MMIO. This way,
  6475. userspace can always sample the device output level and re-compute the state of
  6476. the userspace interrupt controller. Userspace should always check the state
  6477. of run->s.regs.device_irq_level on every kvm exit.
  6478. The value in run->s.regs.device_irq_level can represent both level and edge
  6479. triggered interrupt signals, depending on the device. Edge triggered interrupt
  6480. signals will exit to userspace with the bit in run->s.regs.device_irq_level
  6481. set exactly once per edge signal.
  6482. The field run->s.regs.device_irq_level is available independent of
  6483. run->kvm_valid_regs or run->kvm_dirty_regs bits.
  6484. If KVM_CAP_ARM_USER_IRQ is supported, the KVM_CHECK_EXTENSION ioctl returns a
  6485. number larger than 0 indicating the version of this capability is implemented
  6486. and thereby which bits in run->s.regs.device_irq_level can signal values.
  6487. Currently the following bits are defined for the device_irq_level bitmap::
  6488. KVM_CAP_ARM_USER_IRQ >= 1:
  6489. KVM_ARM_DEV_EL1_VTIMER - EL1 virtual timer
  6490. KVM_ARM_DEV_EL1_PTIMER - EL1 physical timer
  6491. KVM_ARM_DEV_PMU - ARM PMU overflow interrupt signal
  6492. Future versions of kvm may implement additional events. These will get
  6493. indicated by returning a higher number from KVM_CHECK_EXTENSION and will be
  6494. listed above.
  6495. 8.10 KVM_CAP_PPC_SMT_POSSIBLE
  6496. -----------------------------
  6497. :Architectures: ppc
  6498. Querying this capability returns a bitmap indicating the possible
  6499. virtual SMT modes that can be set using KVM_CAP_PPC_SMT. If bit N
  6500. (counting from the right) is set, then a virtual SMT mode of 2^N is
  6501. available.
  6502. 8.11 KVM_CAP_HYPERV_SYNIC2
  6503. --------------------------
  6504. :Architectures: x86
  6505. This capability enables a newer version of Hyper-V Synthetic interrupt
  6506. controller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM
  6507. doesn't clear SynIC message and event flags pages when they are enabled by
  6508. writing to the respective MSRs.
  6509. 8.12 KVM_CAP_HYPERV_VP_INDEX
  6510. ----------------------------
  6511. :Architectures: x86
  6512. This capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its
  6513. value is used to denote the target vcpu for a SynIC interrupt. For
  6514. compatibility, KVM initializes this msr to KVM's internal vcpu index. When this
  6515. capability is absent, userspace can still query this msr's value.
  6516. 8.13 KVM_CAP_S390_AIS_MIGRATION
  6517. -------------------------------
  6518. :Architectures: s390
  6519. :Parameters: none
  6520. This capability indicates if the flic device will be able to get/set the
  6521. AIS states for migration via the KVM_DEV_FLIC_AISM_ALL attribute and allows
  6522. to discover this without having to create a flic device.
  6523. 8.14 KVM_CAP_S390_PSW
  6524. ---------------------
  6525. :Architectures: s390
  6526. This capability indicates that the PSW is exposed via the kvm_run structure.
  6527. 8.15 KVM_CAP_S390_GMAP
  6528. ----------------------
  6529. :Architectures: s390
  6530. This capability indicates that the user space memory used as guest mapping can
  6531. be anywhere in the user memory address space, as long as the memory slots are
  6532. aligned and sized to a segment (1MB) boundary.
  6533. 8.16 KVM_CAP_S390_COW
  6534. ---------------------
  6535. :Architectures: s390
  6536. This capability indicates that the user space memory used as guest mapping can
  6537. use copy-on-write semantics as well as dirty pages tracking via read-only page
  6538. tables.
  6539. 8.17 KVM_CAP_S390_BPB
  6540. ---------------------
  6541. :Architectures: s390
  6542. This capability indicates that kvm will implement the interfaces to handle
  6543. reset, migration and nested KVM for branch prediction blocking. The stfle
  6544. facility 82 should not be provided to the guest without this capability.
  6545. 8.18 KVM_CAP_HYPERV_TLBFLUSH
  6546. ----------------------------
  6547. :Architectures: x86
  6548. This capability indicates that KVM supports paravirtualized Hyper-V TLB Flush
  6549. hypercalls:
  6550. HvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx,
  6551. HvFlushVirtualAddressList, HvFlushVirtualAddressListEx.
  6552. 8.19 KVM_CAP_ARM_INJECT_SERROR_ESR
  6553. ----------------------------------
  6554. :Architectures: arm64
  6555. This capability indicates that userspace can specify (via the
  6556. KVM_SET_VCPU_EVENTS ioctl) the syndrome value reported to the guest when it
  6557. takes a virtual SError interrupt exception.
  6558. If KVM advertises this capability, userspace can only specify the ISS field for
  6559. the ESR syndrome. Other parts of the ESR, such as the EC are generated by the
  6560. CPU when the exception is taken. If this virtual SError is taken to EL1 using
  6561. AArch64, this value will be reported in the ISS field of ESR_ELx.
  6562. See KVM_CAP_VCPU_EVENTS for more details.
  6563. 8.20 KVM_CAP_HYPERV_SEND_IPI
  6564. ----------------------------
  6565. :Architectures: x86
  6566. This capability indicates that KVM supports paravirtualized Hyper-V IPI send
  6567. hypercalls:
  6568. HvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx.
  6569. 8.21 KVM_CAP_HYPERV_DIRECT_TLBFLUSH
  6570. -----------------------------------
  6571. :Architectures: x86
  6572. This capability indicates that KVM running on top of Hyper-V hypervisor
  6573. enables Direct TLB flush for its guests meaning that TLB flush
  6574. hypercalls are handled by Level 0 hypervisor (Hyper-V) bypassing KVM.
  6575. Due to the different ABI for hypercall parameters between Hyper-V and
  6576. KVM, enabling this capability effectively disables all hypercall
  6577. handling by KVM (as some KVM hypercall may be mistakenly treated as TLB
  6578. flush hypercalls by Hyper-V) so userspace should disable KVM identification
  6579. in CPUID and only exposes Hyper-V identification. In this case, guest
  6580. thinks it's running on Hyper-V and only use Hyper-V hypercalls.
  6581. 8.22 KVM_CAP_S390_VCPU_RESETS
  6582. -----------------------------
  6583. :Architectures: s390
  6584. This capability indicates that the KVM_S390_NORMAL_RESET and
  6585. KVM_S390_CLEAR_RESET ioctls are available.
  6586. 8.23 KVM_CAP_S390_PROTECTED
  6587. ---------------------------
  6588. :Architectures: s390
  6589. This capability indicates that the Ultravisor has been initialized and
  6590. KVM can therefore start protected VMs.
  6591. This capability governs the KVM_S390_PV_COMMAND ioctl and the
  6592. KVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected
  6593. guests when the state change is invalid.
  6594. 8.24 KVM_CAP_STEAL_TIME
  6595. -----------------------
  6596. :Architectures: arm64, x86
  6597. This capability indicates that KVM supports steal time accounting.
  6598. When steal time accounting is supported it may be enabled with
  6599. architecture-specific interfaces. This capability and the architecture-
  6600. specific interfaces must be consistent, i.e. if one says the feature
  6601. is supported, than the other should as well and vice versa. For arm64
  6602. see Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL".
  6603. For x86 see Documentation/virt/kvm/x86/msr.rst "MSR_KVM_STEAL_TIME".
  6604. 8.25 KVM_CAP_S390_DIAG318
  6605. -------------------------
  6606. :Architectures: s390
  6607. This capability enables a guest to set information about its control program
  6608. (i.e. guest kernel type and version). The information is helpful during
  6609. system/firmware service events, providing additional data about the guest
  6610. environments running on the machine.
  6611. The information is associated with the DIAGNOSE 0x318 instruction, which sets
  6612. an 8-byte value consisting of a one-byte Control Program Name Code (CPNC) and
  6613. a 7-byte Control Program Version Code (CPVC). The CPNC determines what
  6614. environment the control program is running in (e.g. Linux, z/VM...), and the
  6615. CPVC is used for information specific to OS (e.g. Linux version, Linux
  6616. distribution...)
  6617. If this capability is available, then the CPNC and CPVC can be synchronized
  6618. between KVM and userspace via the sync regs mechanism (KVM_SYNC_DIAG318).
  6619. 8.26 KVM_CAP_X86_USER_SPACE_MSR
  6620. -------------------------------
  6621. :Architectures: x86
  6622. This capability indicates that KVM supports deflection of MSR reads and
  6623. writes to user space. It can be enabled on a VM level. If enabled, MSR
  6624. accesses that would usually trigger a #GP by KVM into the guest will
  6625. instead get bounced to user space through the KVM_EXIT_X86_RDMSR and
  6626. KVM_EXIT_X86_WRMSR exit notifications.
  6627. 8.27 KVM_CAP_X86_MSR_FILTER
  6628. ---------------------------
  6629. :Architectures: x86
  6630. This capability indicates that KVM supports that accesses to user defined MSRs
  6631. may be rejected. With this capability exposed, KVM exports new VM ioctl
  6632. KVM_X86_SET_MSR_FILTER which user space can call to specify bitmaps of MSR
  6633. ranges that KVM should deny access to.
  6634. In combination with KVM_CAP_X86_USER_SPACE_MSR, this allows user space to
  6635. trap and emulate MSRs that are outside of the scope of KVM as well as
  6636. limit the attack surface on KVM's MSR emulation code.
  6637. 8.28 KVM_CAP_ENFORCE_PV_FEATURE_CPUID
  6638. -------------------------------------
  6639. Architectures: x86
  6640. When enabled, KVM will disable paravirtual features provided to the
  6641. guest according to the bits in the KVM_CPUID_FEATURES CPUID leaf
  6642. (0x40000001). Otherwise, a guest may use the paravirtual features
  6643. regardless of what has actually been exposed through the CPUID leaf.
  6644. 8.29 KVM_CAP_DIRTY_LOG_RING/KVM_CAP_DIRTY_LOG_RING_ACQ_REL
  6645. ----------------------------------------------------------
  6646. :Architectures: x86, arm64
  6647. :Parameters: args[0] - size of the dirty log ring
  6648. KVM is capable of tracking dirty memory using ring buffers that are
  6649. mmapped into userspace; there is one dirty ring per vcpu.
  6650. The dirty ring is available to userspace as an array of
  6651. ``struct kvm_dirty_gfn``. Each dirty entry is defined as::
  6652. struct kvm_dirty_gfn {
  6653. __u32 flags;
  6654. __u32 slot; /* as_id | slot_id */
  6655. __u64 offset;
  6656. };
  6657. The following values are defined for the flags field to define the
  6658. current state of the entry::
  6659. #define KVM_DIRTY_GFN_F_DIRTY BIT(0)
  6660. #define KVM_DIRTY_GFN_F_RESET BIT(1)
  6661. #define KVM_DIRTY_GFN_F_MASK 0x3
  6662. Userspace should call KVM_ENABLE_CAP ioctl right after KVM_CREATE_VM
  6663. ioctl to enable this capability for the new guest and set the size of
  6664. the rings. Enabling the capability is only allowed before creating any
  6665. vCPU, and the size of the ring must be a power of two. The larger the
  6666. ring buffer, the less likely the ring is full and the VM is forced to
  6667. exit to userspace. The optimal size depends on the workload, but it is
  6668. recommended that it be at least 64 KiB (4096 entries).
  6669. Just like for dirty page bitmaps, the buffer tracks writes to
  6670. all user memory regions for which the KVM_MEM_LOG_DIRTY_PAGES flag was
  6671. set in KVM_SET_USER_MEMORY_REGION. Once a memory region is registered
  6672. with the flag set, userspace can start harvesting dirty pages from the
  6673. ring buffer.
  6674. An entry in the ring buffer can be unused (flag bits ``00``),
  6675. dirty (flag bits ``01``) or harvested (flag bits ``1X``). The
  6676. state machine for the entry is as follows::
  6677. dirtied harvested reset
  6678. 00 -----------> 01 -------------> 1X -------+
  6679. ^ |
  6680. | |
  6681. +------------------------------------------+
  6682. To harvest the dirty pages, userspace accesses the mmapped ring buffer
  6683. to read the dirty GFNs. If the flags has the DIRTY bit set (at this stage
  6684. the RESET bit must be cleared), then it means this GFN is a dirty GFN.
  6685. The userspace should harvest this GFN and mark the flags from state
  6686. ``01b`` to ``1Xb`` (bit 0 will be ignored by KVM, but bit 1 must be set
  6687. to show that this GFN is harvested and waiting for a reset), and move
  6688. on to the next GFN. The userspace should continue to do this until the
  6689. flags of a GFN have the DIRTY bit cleared, meaning that it has harvested
  6690. all the dirty GFNs that were available.
  6691. Note that on weakly ordered architectures, userspace accesses to the
  6692. ring buffer (and more specifically the 'flags' field) must be ordered,
  6693. using load-acquire/store-release accessors when available, or any
  6694. other memory barrier that will ensure this ordering.
  6695. It's not necessary for userspace to harvest the all dirty GFNs at once.
  6696. However it must collect the dirty GFNs in sequence, i.e., the userspace
  6697. program cannot skip one dirty GFN to collect the one next to it.
  6698. After processing one or more entries in the ring buffer, userspace
  6699. calls the VM ioctl KVM_RESET_DIRTY_RINGS to notify the kernel about
  6700. it, so that the kernel will reprotect those collected GFNs.
  6701. Therefore, the ioctl must be called *before* reading the content of
  6702. the dirty pages.
  6703. The dirty ring can get full. When it happens, the KVM_RUN of the
  6704. vcpu will return with exit reason KVM_EXIT_DIRTY_LOG_FULL.
  6705. The dirty ring interface has a major difference comparing to the
  6706. KVM_GET_DIRTY_LOG interface in that, when reading the dirty ring from
  6707. userspace, it's still possible that the kernel has not yet flushed the
  6708. processor's dirty page buffers into the kernel buffer (with dirty bitmaps, the
  6709. flushing is done by the KVM_GET_DIRTY_LOG ioctl). To achieve that, one
  6710. needs to kick the vcpu out of KVM_RUN using a signal. The resulting
  6711. vmexit ensures that all dirty GFNs are flushed to the dirty rings.
  6712. NOTE: KVM_CAP_DIRTY_LOG_RING_ACQ_REL is the only capability that
  6713. should be exposed by weakly ordered architecture, in order to indicate
  6714. the additional memory ordering requirements imposed on userspace when
  6715. reading the state of an entry and mutating it from DIRTY to HARVESTED.
  6716. Architecture with TSO-like ordering (such as x86) are allowed to
  6717. expose both KVM_CAP_DIRTY_LOG_RING and KVM_CAP_DIRTY_LOG_RING_ACQ_REL
  6718. to userspace.
  6719. After enabling the dirty rings, the userspace needs to detect the
  6720. capability of KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP to see whether the
  6721. ring structures can be backed by per-slot bitmaps. With this capability
  6722. advertised, it means the architecture can dirty guest pages without
  6723. vcpu/ring context, so that some of the dirty information will still be
  6724. maintained in the bitmap structure. KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP
  6725. can't be enabled if the capability of KVM_CAP_DIRTY_LOG_RING_ACQ_REL
  6726. hasn't been enabled, or any memslot has been existing.
  6727. Note that the bitmap here is only a backup of the ring structure. The
  6728. use of the ring and bitmap combination is only beneficial if there is
  6729. only a very small amount of memory that is dirtied out of vcpu/ring
  6730. context. Otherwise, the stand-alone per-slot bitmap mechanism needs to
  6731. be considered.
  6732. To collect dirty bits in the backup bitmap, userspace can use the same
  6733. KVM_GET_DIRTY_LOG ioctl. KVM_CLEAR_DIRTY_LOG isn't needed as long as all
  6734. the generation of the dirty bits is done in a single pass. Collecting
  6735. the dirty bitmap should be the very last thing that the VMM does before
  6736. considering the state as complete. VMM needs to ensure that the dirty
  6737. state is final and avoid missing dirty pages from another ioctl ordered
  6738. after the bitmap collection.
  6739. NOTE: Multiple examples of using the backup bitmap: (1) save vgic/its
  6740. tables through command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_SAVE_TABLES} on
  6741. KVM device "kvm-arm-vgic-its". (2) restore vgic/its tables through
  6742. command KVM_DEV_ARM_{VGIC_GRP_CTRL, ITS_RESTORE_TABLES} on KVM device
  6743. "kvm-arm-vgic-its". VGICv3 LPI pending status is restored. (3) save
  6744. vgic3 pending table through KVM_DEV_ARM_VGIC_{GRP_CTRL, SAVE_PENDING_TABLES}
  6745. command on KVM device "kvm-arm-vgic-v3".
  6746. 8.30 KVM_CAP_XEN_HVM
  6747. --------------------
  6748. :Architectures: x86
  6749. This capability indicates the features that Xen supports for hosting Xen
  6750. PVHVM guests. Valid flags are::
  6751. #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0)
  6752. #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
  6753. #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
  6754. #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
  6755. #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4)
  6756. #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
  6757. #define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6)
  6758. #define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7)
  6759. The KVM_XEN_HVM_CONFIG_HYPERCALL_MSR flag indicates that the KVM_XEN_HVM_CONFIG
  6760. ioctl is available, for the guest to set its hypercall page.
  6761. If KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL is also set, the same flag may also be
  6762. provided in the flags to KVM_XEN_HVM_CONFIG, without providing hypercall page
  6763. contents, to request that KVM generate hypercall page content automatically
  6764. and also enable interception of guest hypercalls with KVM_EXIT_XEN.
  6765. The KVM_XEN_HVM_CONFIG_SHARED_INFO flag indicates the availability of the
  6766. KVM_XEN_HVM_SET_ATTR, KVM_XEN_HVM_GET_ATTR, KVM_XEN_VCPU_SET_ATTR and
  6767. KVM_XEN_VCPU_GET_ATTR ioctls, as well as the delivery of exception vectors
  6768. for event channel upcalls when the evtchn_upcall_pending field of a vcpu's
  6769. vcpu_info is set.
  6770. The KVM_XEN_HVM_CONFIG_RUNSTATE flag indicates that the runstate-related
  6771. features KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR/_CURRENT/_DATA/_ADJUST are
  6772. supported by the KVM_XEN_VCPU_SET_ATTR/KVM_XEN_VCPU_GET_ATTR ioctls.
  6773. The KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL flag indicates that IRQ routing entries
  6774. of the type KVM_IRQ_ROUTING_XEN_EVTCHN are supported, with the priority
  6775. field set to indicate 2 level event channel delivery.
  6776. The KVM_XEN_HVM_CONFIG_EVTCHN_SEND flag indicates that KVM supports
  6777. injecting event channel events directly into the guest with the
  6778. KVM_XEN_HVM_EVTCHN_SEND ioctl. It also indicates support for the
  6779. KVM_XEN_ATTR_TYPE_EVTCHN/XEN_VERSION HVM attributes and the
  6780. KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID/TIMER/UPCALL_VECTOR vCPU attributes.
  6781. related to event channel delivery, timers, and the XENVER_version
  6782. interception.
  6783. The KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG flag indicates that KVM supports
  6784. the KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG attribute in the KVM_XEN_SET_ATTR
  6785. and KVM_XEN_GET_ATTR ioctls. This controls whether KVM will set the
  6786. XEN_RUNSTATE_UPDATE flag in guest memory mapped vcpu_runstate_info during
  6787. updates of the runstate information. Note that versions of KVM which support
  6788. the RUNSTATE feature above, but not the RUNSTATE_UPDATE_FLAG feature, will
  6789. always set the XEN_RUNSTATE_UPDATE flag when updating the guest structure,
  6790. which is perhaps counterintuitive. When this flag is advertised, KVM will
  6791. behave more correctly, not using the XEN_RUNSTATE_UPDATE flag until/unless
  6792. specifically enabled (by the guest making the hypercall, causing the VMM
  6793. to enable the KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG attribute).
  6794. The KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE flag indicates that KVM supports
  6795. clearing the PVCLOCK_TSC_STABLE_BIT flag in Xen pvclock sources. This will be
  6796. done when the KVM_CAP_XEN_HVM ioctl sets the
  6797. KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE flag.
  6798. 8.31 KVM_CAP_PPC_MULTITCE
  6799. -------------------------
  6800. :Capability: KVM_CAP_PPC_MULTITCE
  6801. :Architectures: ppc
  6802. :Type: vm
  6803. This capability means the kernel is capable of handling hypercalls
  6804. H_PUT_TCE_INDIRECT and H_STUFF_TCE without passing those into the user
  6805. space. This significantly accelerates DMA operations for PPC KVM guests.
  6806. User space should expect that its handlers for these hypercalls
  6807. are not going to be called if user space previously registered LIOBN
  6808. in KVM (via KVM_CREATE_SPAPR_TCE or similar calls).
  6809. In order to enable H_PUT_TCE_INDIRECT and H_STUFF_TCE use in the guest,
  6810. user space might have to advertise it for the guest. For example,
  6811. IBM pSeries (sPAPR) guest starts using them if "hcall-multi-tce" is
  6812. present in the "ibm,hypertas-functions" device-tree property.
  6813. The hypercalls mentioned above may or may not be processed successfully
  6814. in the kernel based fast path. If they can not be handled by the kernel,
  6815. they will get passed on to user space. So user space still has to have
  6816. an implementation for these despite the in kernel acceleration.
  6817. This capability is always enabled.
  6818. 8.32 KVM_CAP_PTP_KVM
  6819. --------------------
  6820. :Architectures: arm64
  6821. This capability indicates that the KVM virtual PTP service is
  6822. supported in the host. A VMM can check whether the service is
  6823. available to the guest on migration.
  6824. 8.33 KVM_CAP_HYPERV_ENFORCE_CPUID
  6825. ---------------------------------
  6826. Architectures: x86
  6827. When enabled, KVM will disable emulated Hyper-V features provided to the
  6828. guest according to the bits Hyper-V CPUID feature leaves. Otherwise, all
  6829. currently implemented Hyper-V features are provided unconditionally when
  6830. Hyper-V identification is set in the HYPERV_CPUID_INTERFACE (0x40000001)
  6831. leaf.
  6832. 8.34 KVM_CAP_EXIT_HYPERCALL
  6833. ---------------------------
  6834. :Capability: KVM_CAP_EXIT_HYPERCALL
  6835. :Architectures: x86
  6836. :Type: vm
  6837. This capability, if enabled, will cause KVM to exit to userspace
  6838. with KVM_EXIT_HYPERCALL exit reason to process some hypercalls.
  6839. Calling KVM_CHECK_EXTENSION for this capability will return a bitmask
  6840. of hypercalls that can be configured to exit to userspace.
  6841. Right now, the only such hypercall is KVM_HC_MAP_GPA_RANGE.
  6842. The argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset
  6843. of the result of KVM_CHECK_EXTENSION. KVM will forward to userspace
  6844. the hypercalls whose corresponding bit is in the argument, and return
  6845. ENOSYS for the others.
  6846. 8.35 KVM_CAP_PMU_CAPABILITY
  6847. ---------------------------
  6848. :Capability: KVM_CAP_PMU_CAPABILITY
  6849. :Architectures: x86
  6850. :Type: vm
  6851. :Parameters: arg[0] is bitmask of PMU virtualization capabilities.
  6852. :Returns: 0 on success, -EINVAL when arg[0] contains invalid bits
  6853. This capability alters PMU virtualization in KVM.
  6854. Calling KVM_CHECK_EXTENSION for this capability returns a bitmask of
  6855. PMU virtualization capabilities that can be adjusted on a VM.
  6856. The argument to KVM_ENABLE_CAP is also a bitmask and selects specific
  6857. PMU virtualization capabilities to be applied to the VM. This can
  6858. only be invoked on a VM prior to the creation of VCPUs.
  6859. At this time, KVM_PMU_CAP_DISABLE is the only capability. Setting
  6860. this capability will disable PMU virtualization for that VM. Usermode
  6861. should adjust CPUID leaf 0xA to reflect that the PMU is disabled.
  6862. 8.36 KVM_CAP_ARM_SYSTEM_SUSPEND
  6863. -------------------------------
  6864. :Capability: KVM_CAP_ARM_SYSTEM_SUSPEND
  6865. :Architectures: arm64
  6866. :Type: vm
  6867. When enabled, KVM will exit to userspace with KVM_EXIT_SYSTEM_EVENT of
  6868. type KVM_SYSTEM_EVENT_SUSPEND to process the guest suspend request.
  6869. 8.37 KVM_CAP_S390_PROTECTED_DUMP
  6870. --------------------------------
  6871. :Capability: KVM_CAP_S390_PROTECTED_DUMP
  6872. :Architectures: s390
  6873. :Type: vm
  6874. This capability indicates that KVM and the Ultravisor support dumping
  6875. PV guests. The `KVM_PV_DUMP` command is available for the
  6876. `KVM_S390_PV_COMMAND` ioctl and the `KVM_PV_INFO` command provides
  6877. dump related UV data. Also the vcpu ioctl `KVM_S390_PV_CPU_COMMAND` is
  6878. available and supports the `KVM_PV_DUMP_CPU` subcommand.
  6879. 8.38 KVM_CAP_VM_DISABLE_NX_HUGE_PAGES
  6880. -------------------------------------
  6881. :Capability: KVM_CAP_VM_DISABLE_NX_HUGE_PAGES
  6882. :Architectures: x86
  6883. :Type: vm
  6884. :Parameters: arg[0] must be 0.
  6885. :Returns: 0 on success, -EPERM if the userspace process does not
  6886. have CAP_SYS_BOOT, -EINVAL if args[0] is not 0 or any vCPUs have been
  6887. created.
  6888. This capability disables the NX huge pages mitigation for iTLB MULTIHIT.
  6889. The capability has no effect if the nx_huge_pages module parameter is not set.
  6890. This capability may only be set before any vCPUs are created.
  6891. 8.39 KVM_CAP_S390_CPU_TOPOLOGY
  6892. ------------------------------
  6893. :Capability: KVM_CAP_S390_CPU_TOPOLOGY
  6894. :Architectures: s390
  6895. :Type: vm
  6896. This capability indicates that KVM will provide the S390 CPU Topology
  6897. facility which consist of the interpretation of the PTF instruction for
  6898. the function code 2 along with interception and forwarding of both the
  6899. PTF instruction with function codes 0 or 1 and the STSI(15,1,x)
  6900. instruction to the userland hypervisor.
  6901. The stfle facility 11, CPU Topology facility, should not be indicated
  6902. to the guest without this capability.
  6903. When this capability is present, KVM provides a new attribute group
  6904. on vm fd, KVM_S390_VM_CPU_TOPOLOGY.
  6905. This new attribute allows to get, set or clear the Modified Change
  6906. Topology Report (MTCR) bit of the SCA through the kvm_device_attr
  6907. structure.
  6908. When getting the Modified Change Topology Report value, the attr->addr
  6909. must point to a byte where the value will be stored or retrieved from.
  6910. 8.40 KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE
  6911. ---------------------------------------
  6912. :Capability: KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE
  6913. :Architectures: arm64
  6914. :Type: vm
  6915. :Parameters: arg[0] is the new split chunk size.
  6916. :Returns: 0 on success, -EINVAL if any memslot was already created.
  6917. This capability sets the chunk size used in Eager Page Splitting.
  6918. Eager Page Splitting improves the performance of dirty-logging (used
  6919. in live migrations) when guest memory is backed by huge-pages. It
  6920. avoids splitting huge-pages (into PAGE_SIZE pages) on fault, by doing
  6921. it eagerly when enabling dirty logging (with the
  6922. KVM_MEM_LOG_DIRTY_PAGES flag for a memory region), or when using
  6923. KVM_CLEAR_DIRTY_LOG.
  6924. The chunk size specifies how many pages to break at a time, using a
  6925. single allocation for each chunk. Bigger the chunk size, more pages
  6926. need to be allocated ahead of time.
  6927. The chunk size needs to be a valid block size. The list of acceptable
  6928. block sizes is exposed in KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES as a
  6929. 64-bit bitmap (each bit describing a block size). The default value is
  6930. 0, to disable the eager page splitting.
  6931. 8.41 KVM_CAP_VM_TYPES
  6932. ---------------------
  6933. :Capability: KVM_CAP_MEMORY_ATTRIBUTES
  6934. :Architectures: x86
  6935. :Type: system ioctl
  6936. This capability returns a bitmap of support VM types. The 1-setting of bit @n
  6937. means the VM type with value @n is supported. Possible values of @n are::
  6938. #define KVM_X86_DEFAULT_VM 0
  6939. #define KVM_X86_SW_PROTECTED_VM 1
  6940. #define KVM_X86_SEV_VM 2
  6941. #define KVM_X86_SEV_ES_VM 3
  6942. Note, KVM_X86_SW_PROTECTED_VM is currently only for development and testing.
  6943. Do not use KVM_X86_SW_PROTECTED_VM for "real" VMs, and especially not in
  6944. production. The behavior and effective ABI for software-protected VMs is
  6945. unstable.
  6946. 9. Known KVM API problems
  6947. =========================
  6948. In some cases, KVM's API has some inconsistencies or common pitfalls
  6949. that userspace need to be aware of. This section details some of
  6950. these issues.
  6951. Most of them are architecture specific, so the section is split by
  6952. architecture.
  6953. 9.1. x86
  6954. --------
  6955. ``KVM_GET_SUPPORTED_CPUID`` issues
  6956. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6957. In general, ``KVM_GET_SUPPORTED_CPUID`` is designed so that it is possible
  6958. to take its result and pass it directly to ``KVM_SET_CPUID2``. This section
  6959. documents some cases in which that requires some care.
  6960. Local APIC features
  6961. ~~~~~~~~~~~~~~~~~~~
  6962. CPU[EAX=1]:ECX[21] (X2APIC) is reported by ``KVM_GET_SUPPORTED_CPUID``,
  6963. but it can only be enabled if ``KVM_CREATE_IRQCHIP`` or
  6964. ``KVM_ENABLE_CAP(KVM_CAP_IRQCHIP_SPLIT)`` are used to enable in-kernel emulation of
  6965. the local APIC.
  6966. The same is true for the ``KVM_FEATURE_PV_UNHALT`` paravirtualized feature.
  6967. CPU[EAX=1]:ECX[24] (TSC_DEADLINE) is not reported by ``KVM_GET_SUPPORTED_CPUID``.
  6968. It can be enabled if ``KVM_CAP_TSC_DEADLINE_TIMER`` is present and the kernel
  6969. has enabled in-kernel emulation of the local APIC.
  6970. CPU topology
  6971. ~~~~~~~~~~~~
  6972. Several CPUID values include topology information for the host CPU:
  6973. 0x0b and 0x1f for Intel systems, 0x8000001e for AMD systems. Different
  6974. versions of KVM return different values for this information and userspace
  6975. should not rely on it. Currently they return all zeroes.
  6976. If userspace wishes to set up a guest topology, it should be careful that
  6977. the values of these three leaves differ for each CPU. In particular,
  6978. the APIC ID is found in EDX for all subleaves of 0x0b and 0x1f, and in EAX
  6979. for 0x8000001e; the latter also encodes the core id and node id in bits
  6980. 7:0 of EBX and ECX respectively.
  6981. Obsolete ioctls and capabilities
  6982. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6983. KVM_CAP_DISABLE_QUIRKS does not let userspace know which quirks are actually
  6984. available. Use ``KVM_CHECK_EXTENSION(KVM_CAP_DISABLE_QUIRKS2)`` instead if
  6985. available.
  6986. Ordering of KVM_GET_*/KVM_SET_* ioctls
  6987. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6988. TBD