Documentation/virt/kvm/loongarch/hypercalls.rst

Source file repositories/reference/linux-study-clean/Documentation/virt/kvm/loongarch/hypercalls.rst

File Facts

System
Linux kernel
Corpus path
Documentation/virt/kvm/loongarch/hypercalls.rst
Extension
.rst
Size
3002 bytes
Lines
90
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

.. SPDX-License-Identifier: GPL-2.0

===================================
The LoongArch paravirtual interface
===================================

KVM hypercalls use the HVCL instruction with code 0x100 and the hypercall
number is put in a0. Up to five arguments may be placed in registers a1 - a5.
The return value is placed in v0 (an alias of a0).

Source code for this interface can be found in arch/loongarch/kvm*.

Querying for existence
======================

To determine if the host is running on KVM, we can utilize the cpucfg()
function at index CPUCFG_KVM_BASE (0x40000000).

The CPUCFG_KVM_BASE range, spanning from 0x40000000 to 0x400000FF, The
CPUCFG_KVM_BASE range between 0x40000000 - 0x400000FF is marked as reserved.
Consequently, all current and future processors will not implement any
feature within this range.

On a KVM-virtualized Linux system, a read operation on cpucfg() at index
CPUCFG_KVM_BASE (0x40000000) returns the magic string 'KVM\0'.

Once you have determined that your host is running on a paravirtualization-
capable KVM, you may now use hypercalls as described below.

KVM hypercall ABI
=================

The KVM hypercall ABI is simple, with one scratch register a0 (v0) and at most
five generic registers (a1 - a5) used as input parameters. The FP (Floating-
point) and vector registers are not utilized as input registers and must
remain unmodified during a hypercall.

Hypercall functions can be inlined as it only uses one scratch register.

The parameters are as follows:

	========	=================	================
	Register	IN			OUT
	========	=================	================
	a0		function number		Return	code
	a1		1st	parameter	-
	a2		2nd	parameter	-
	a3		3rd	parameter	-
	a4		4th	parameter	-
	a5		5th	parameter	-
	========	=================	================

The return codes may be one of the following:

	====		=========================
	Code		Meaning
	====		=========================
	0		Success
	-1		Hypercall not implemented
	-2		Bad Hypercall parameter
	====		=========================

KVM Hypercalls Documentation
============================

The template for each hypercall is as follows:

1. Hypercall name
2. Purpose

Annotation

Implementation Notes