1Linux KVM Hypercall: 2=================== 3X86: 4 KVM Hypercalls have a three-byte sequence of either the vmcall or the vmmcall 5 instruction. The hypervisor can replace it with instructions that are 6 guaranteed to be supported. 7 8 Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively. 9 The hypercall number should be placed in rax and the return value will be 10 placed in rax. No other registers will be clobbered unless explicitly stated 11 by the particular hypercall. 12 13S390: 14 R2-R7 are used for parameters 1-6. In addition, R1 is used for hypercall 15 number. The return value is written to R2. 16 17 S390 uses diagnose instruction as hypercall (0x500) along with hypercall 18 number in R1. 19 20 For further information on the S390 diagnose call as supported by KVM, 21 refer to Documentation/virtual/kvm/s390-diag.txt. 22 23 PowerPC: 24 It uses R3-R10 and hypercall number in R11. R4-R11 are used as output registers. 25 Return value is placed in R3. 26 27 KVM hypercalls uses 4 byte opcode, that are patched with 'hypercall-instructions' 28 property inside the device tree's /hypervisor node. 29 For more information refer to Documentation/virtual/kvm/ppc-pv.txt 30 31KVM Hypercalls Documentation 32=========================== 33The template for each hypercall is: 341. Hypercall name. 352. Architecture(s) 363. Status (deprecated, obsolete, active) 374. Purpose 38 391. KVM_HC_VAPIC_POLL_IRQ 40------------------------ 41Architecture: x86 42Status: active 43Purpose: Trigger guest exit so that the host can check for pending 44interrupts on reentry. 45 462. KVM_HC_MMU_OP 47------------------------ 48Architecture: x86 49Status: deprecated. 50Purpose: Support MMU operations such as writing to PTE, 51flushing TLB, release PT. 52 533. KVM_HC_FEATURES 54------------------------ 55Architecture: PPC 56Status: active 57Purpose: Expose hypercall availability to the guest. On x86 platforms, cpuid 58used to enumerate which hypercalls are available. On PPC, either device tree 59based lookup ( which is also what EPAPR dictates) OR KVM specific enumeration 60mechanism (which is this hypercall) can be used. 61 624. KVM_HC_PPC_MAP_MAGIC_PAGE 63------------------------ 64Architecture: PPC 65Status: active 66Purpose: To enable communication between the hypervisor and guest there is a 67shared page that contains parts of supervisor visible register state. 68The guest can map this shared page to access its supervisor register through 69memory using this hypercall. 70 715. KVM_HC_KICK_CPU 72------------------------ 73Architecture: x86 74Status: active 75Purpose: Hypercall used to wakeup a vcpu from HLT state 76Usage example : A vcpu of a paravirtualized guest that is busywaiting in guest 77kernel mode for an event to occur (ex: a spinlock to become available) can 78execute HLT instruction once it has busy-waited for more than a threshold 79time-interval. Execution of HLT instruction would cause the hypervisor to put 80the vcpu to sleep until occurrence of an appropriate event. Another vcpu of the 81same guest can wakeup the sleeping vcpu by issuing KVM_HC_KICK_CPU hypercall, 82specifying APIC ID (a1) of the vcpu to be woken up. An additional argument (a0) 83is used in the hypercall for future use. 84