brintos

brintos / linux-shallow public Read only

0
0
Text · 2.9 KiB · 2d6b940 Raw
90 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3===================================4The LoongArch paravirtual interface5===================================6 7KVM hypercalls use the HVCL instruction with code 0x100 and the hypercall8number is put in a0. Up to five arguments may be placed in registers a1 - a5.9The return value is placed in v0 (an alias of a0).10 11Source code for this interface can be found in arch/loongarch/kvm*.12 13Querying for existence14======================15 16To determine if the host is running on KVM, we can utilize the cpucfg()17function at index CPUCFG_KVM_BASE (0x40000000).18 19The CPUCFG_KVM_BASE range, spanning from 0x40000000 to 0x400000FF, The20CPUCFG_KVM_BASE range between 0x40000000 - 0x400000FF is marked as reserved.21Consequently, all current and future processors will not implement any22feature within this range.23 24On a KVM-virtualized Linux system, a read operation on cpucfg() at index25CPUCFG_KVM_BASE (0x40000000) returns the magic string 'KVM\0'.26 27Once you have determined that your host is running on a paravirtualization-28capable KVM, you may now use hypercalls as described below.29 30KVM hypercall ABI31=================32 33The KVM hypercall ABI is simple, with one scratch register a0 (v0) and at most34five generic registers (a1 - a5) used as input parameters. The FP (Floating-35point) and vector registers are not utilized as input registers and must36remain unmodified during a hypercall.37 38Hypercall functions can be inlined as it only uses one scratch register.39 40The parameters are as follows:41 42	========	=================	================43	Register	IN			OUT44	========	=================	================45	a0		function number		Return	code46	a1		1st	parameter	-47	a2		2nd	parameter	-48	a3		3rd	parameter	-49	a4		4th	parameter	-50	a5		5th	parameter	-51	========	=================	================52 53The return codes may be one of the following:54 55	====		=========================56	Code		Meaning57	====		=========================58	0		Success59	-1		Hypercall not implemented60	-2		Bad Hypercall parameter61	====		=========================62 63KVM Hypercalls Documentation64============================65 66The template for each hypercall is as follows:67 681. Hypercall name692. Purpose70 711. KVM_HCALL_FUNC_IPI72------------------------73 74:Purpose: Send IPIs to multiple vCPUs.75 76- a0: KVM_HCALL_FUNC_IPI77- a1: Lower part of the bitmap for destination physical CPUIDs78- a2: Higher part of the bitmap for destination physical CPUIDs79- a3: The lowest physical CPUID in the bitmap80 81The hypercall lets a guest send multiple IPIs (Inter-Process Interrupts) with82at most 128 destinations per hypercall. The destinations are represented in a83bitmap contained in the first two input registers (a1 and a2).84 85Bit 0 of a1 corresponds to the physical CPUID in the third input register (a3)86and bit 1 corresponds to the physical CPUID in a3+1, and so on.87 88PV IPI on LoongArch includes both PV IPI multicast sending and PV IPI receiving,89and SWI is used for PV IPI inject since there is no VM-exits accessing SWI registers.90