@@ -416,6 +416,13 @@ Reads the general purpose registers from the vcpu.
416416 __u64 pc;
417417 };
418418
419+ /* LoongArch */
420+ struct kvm_regs {
421+ /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
422+ unsigned long gpr[32];
423+ unsigned long pc;
424+ };
425+
419426
4204274.12 KVM_SET_REGS
421428-----------------
@@ -506,7 +513,7 @@ translation mode.
506513------------------
507514
508515:Capability: basic
509- :Architectures: x86, ppc, mips, riscv
516+ :Architectures: x86, ppc, mips, riscv, loongarch
510517:Type: vcpu ioctl
511518:Parameters: struct kvm_interrupt (in)
512519:Returns: 0 on success, negative on failure.
@@ -592,6 +599,14 @@ b) KVM_INTERRUPT_UNSET
592599
593600This is an asynchronous vcpu ioctl and can be invoked from any thread.
594601
602+ LOONGARCH:
603+ ^^^^^^^^^^
604+
605+ Queues an external interrupt to be injected into the virtual CPU. A negative
606+ interrupt number dequeues the interrupt.
607+
608+ This is an asynchronous vcpu ioctl and can be invoked from any thread.
609+
595610
5966114.17 KVM_DEBUG_GUEST
597612--------------------
@@ -737,7 +752,7 @@ signal mask.
737752----------------
738753
739754:Capability: basic
740- :Architectures: x86
755+ :Architectures: x86, loongarch
741756:Type: vcpu ioctl
742757:Parameters: struct kvm_fpu (out)
743758:Returns: 0 on success, -1 on error
@@ -746,7 +761,7 @@ Reads the floating point state from the vcpu.
746761
747762::
748763
749- /* for KVM_GET_FPU and KVM_SET_FPU */
764+ /* x86: for KVM_GET_FPU and KVM_SET_FPU */
750765 struct kvm_fpu {
751766 __u8 fpr[8][16];
752767 __u16 fcw;
@@ -761,12 +776,21 @@ Reads the floating point state from the vcpu.
761776 __u32 pad2;
762777 };
763778
779+ /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */
780+ struct kvm_fpu {
781+ __u32 fcsr;
782+ __u64 fcc;
783+ struct kvm_fpureg {
784+ __u64 val64[4];
785+ }fpr[32];
786+ };
787+
764788
7657894.23 KVM_SET_FPU
766790----------------
767791
768792:Capability: basic
769- :Architectures: x86
793+ :Architectures: x86, loongarch
770794:Type: vcpu ioctl
771795:Parameters: struct kvm_fpu (in)
772796:Returns: 0 on success, -1 on error
@@ -775,7 +799,7 @@ Writes the floating point state to the vcpu.
775799
776800::
777801
778- /* for KVM_GET_FPU and KVM_SET_FPU */
802+ /* x86: for KVM_GET_FPU and KVM_SET_FPU */
779803 struct kvm_fpu {
780804 __u8 fpr[8][16];
781805 __u16 fcw;
@@ -790,6 +814,15 @@ Writes the floating point state to the vcpu.
790814 __u32 pad2;
791815 };
792816
817+ /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */
818+ struct kvm_fpu {
819+ __u32 fcsr;
820+ __u64 fcc;
821+ struct kvm_fpureg {
822+ __u64 val64[4];
823+ }fpr[32];
824+ };
825+
793826
7948274.24 KVM_CREATE_IRQCHIP
795828-----------------------
@@ -1387,7 +1420,7 @@ documentation when it pops into existence).
13871420-------------------
13881421
13891422:Capability: KVM_CAP_ENABLE_CAP
1390- :Architectures: mips, ppc, s390, x86
1423+ :Architectures: mips, ppc, s390, x86, loongarch
13911424:Type: vcpu ioctl
13921425:Parameters: struct kvm_enable_cap (in)
13931426:Returns: 0 on success; -1 on error
@@ -1442,7 +1475,7 @@ for vm-wide capabilities.
14421475---------------------
14431476
14441477:Capability: KVM_CAP_MP_STATE
1445- :Architectures: x86, s390, arm64, riscv
1478+ :Architectures: x86, s390, arm64, riscv, loongarch
14461479:Type: vcpu ioctl
14471480:Parameters: struct kvm_mp_state (out)
14481481:Returns: 0 on success; -1 on error
@@ -1460,7 +1493,7 @@ Possible values are:
14601493
14611494 ========================== ===============================================
14621495 KVM_MP_STATE_RUNNABLE the vcpu is currently running
1463- [x86,arm64,riscv]
1496+ [x86,arm64,riscv,loongarch ]
14641497 KVM_MP_STATE_UNINITIALIZED the vcpu is an application processor (AP)
14651498 which has not yet received an INIT signal [x86]
14661499 KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, and is
@@ -1516,11 +1549,14 @@ For riscv:
15161549The only states that are valid are KVM_MP_STATE_STOPPED and
15171550KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not.
15181551
1552+ On LoongArch, only the KVM_MP_STATE_RUNNABLE state is used to reflect
1553+ whether the vcpu is runnable.
1554+
151915554.39 KVM_SET_MP_STATE
15201556---------------------
15211557
15221558:Capability: KVM_CAP_MP_STATE
1523- :Architectures: x86, s390, arm64, riscv
1559+ :Architectures: x86, s390, arm64, riscv, loongarch
15241560:Type: vcpu ioctl
15251561:Parameters: struct kvm_mp_state (in)
15261562:Returns: 0 on success; -1 on error
@@ -1538,6 +1574,9 @@ For arm64/riscv:
15381574The only states that are valid are KVM_MP_STATE_STOPPED and
15391575KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not.
15401576
1577+ On LoongArch, only the KVM_MP_STATE_RUNNABLE state is used to reflect
1578+ whether the vcpu is runnable.
1579+
154115804.40 KVM_SET_IDENTITY_MAP_ADDR
15421581------------------------------
15431582
@@ -2841,6 +2880,19 @@ Following are the RISC-V D-extension registers:
28412880 0x8020 0000 0600 0020 fcsr Floating point control and status register
28422881======================= ========= =============================================
28432882
2883+ LoongArch registers are mapped using the lower 32 bits. The upper 16 bits of
2884+ that is the register group type.
2885+
2886+ LoongArch csr registers are used to control guest cpu or get status of guest
2887+ cpu, and they have the following id bit patterns::
2888+
2889+ 0x9030 0000 0001 00 <reg:5> <sel:3> (64-bit)
2890+
2891+ LoongArch KVM control registers are used to implement some new defined functions
2892+ such as set vcpu counter or reset vcpu, and they have the following id bit patterns::
2893+
2894+ 0x9030 0000 0002 <reg:16>
2895+
28442896
284528974.69 KVM_GET_ONE_REG
28462898--------------------
0 commit comments