All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Tianrui Zhao <zhaotianrui@loongson.cn>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	loongarch@lists.linux.dev, Jens Axboe <axboe@kernel.dk>,
	Mark Brown <broonie@kernel.org>,
	Alex Deucher <alexander.deucher@amd.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	maobibo@loongson.cn, Xi Ruoyao <xry111@xry111.site>,
	zhaotianrui@loongson.cn, Huacai Chen <chenhuacai@loongson.cn>
Subject: [PATCH v20 29/30] LoongArch: KVM: Supplement kvm document about LoongArch-specific part
Date: Thu, 31 Aug 2023 16:30:19 +0800	[thread overview]
Message-ID: <20230831083020.2187109-30-zhaotianrui@loongson.cn> (raw)
In-Reply-To: <20230831083020.2187109-1-zhaotianrui@loongson.cn>

Supplement kvm document about LoongArch-specific part, such as add
api introduction for GET/SET_ONE_REG, GET/SET_FPU, GET/SET_MP_STATE,
etc.

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
 Documentation/virt/kvm/api.rst | 70 +++++++++++++++++++++++++++++-----
 1 file changed, 61 insertions(+), 9 deletions(-)

diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index c0ddd30354..8ad10ec17a 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -416,6 +416,13 @@ Reads the general purpose registers from the vcpu.
 	__u64 pc;
   };
 
+  /* LoongArch */
+  struct kvm_regs {
+	/* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
+        unsigned long gpr[32];
+        unsigned long pc;
+  };
+
 
 4.12 KVM_SET_REGS
 -----------------
@@ -506,7 +513,7 @@ translation mode.
 ------------------
 
 :Capability: basic
-:Architectures: x86, ppc, mips, riscv
+:Architectures: x86, ppc, mips, riscv, loongarch
 :Type: vcpu ioctl
 :Parameters: struct kvm_interrupt (in)
 :Returns: 0 on success, negative on failure.
@@ -592,6 +599,14 @@ b) KVM_INTERRUPT_UNSET
 
 This is an asynchronous vcpu ioctl and can be invoked from any thread.
 
+LOONGARCH:
+^^^^^^^^^^
+
+Queues an external interrupt to be injected into the virtual CPU. A negative
+interrupt number dequeues the interrupt.
+
+This is an asynchronous vcpu ioctl and can be invoked from any thread.
+
 
 4.17 KVM_DEBUG_GUEST
 --------------------
@@ -737,7 +752,7 @@ signal mask.
 ----------------
 
 :Capability: basic
-:Architectures: x86
+:Architectures: x86, loongarch
 :Type: vcpu ioctl
 :Parameters: struct kvm_fpu (out)
 :Returns: 0 on success, -1 on error
@@ -746,7 +761,7 @@ Reads the floating point state from the vcpu.
 
 ::
 
-  /* for KVM_GET_FPU and KVM_SET_FPU */
+  /* x86: for KVM_GET_FPU and KVM_SET_FPU */
   struct kvm_fpu {
 	__u8  fpr[8][16];
 	__u16 fcw;
@@ -761,12 +776,21 @@ Reads the floating point state from the vcpu.
 	__u32 pad2;
   };
 
+  /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */
+  struct kvm_fpu {
+        __u32 fcsr;
+        __u64 fcc;
+        struct kvm_fpureg {
+                __u64 val64[4];
+        }fpr[32];
+  };
+
 
 4.23 KVM_SET_FPU
 ----------------
 
 :Capability: basic
-:Architectures: x86
+:Architectures: x86, loongarch
 :Type: vcpu ioctl
 :Parameters: struct kvm_fpu (in)
 :Returns: 0 on success, -1 on error
@@ -775,7 +799,7 @@ Writes the floating point state to the vcpu.
 
 ::
 
-  /* for KVM_GET_FPU and KVM_SET_FPU */
+  /* x86: for KVM_GET_FPU and KVM_SET_FPU */
   struct kvm_fpu {
 	__u8  fpr[8][16];
 	__u16 fcw;
@@ -790,6 +814,15 @@ Writes the floating point state to the vcpu.
 	__u32 pad2;
   };
 
+  /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */
+  struct kvm_fpu {
+        __u32 fcsr;
+        __u64 fcc;
+        struct kvm_fpureg {
+                __u64 val64[4];
+        }fpr[32];
+  };
+
 
 4.24 KVM_CREATE_IRQCHIP
 -----------------------
@@ -1387,7 +1420,7 @@ documentation when it pops into existence).
 -------------------
 
 :Capability: KVM_CAP_ENABLE_CAP
-:Architectures: mips, ppc, s390, x86
+:Architectures: mips, ppc, s390, x86, loongarch
 :Type: vcpu ioctl
 :Parameters: struct kvm_enable_cap (in)
 :Returns: 0 on success; -1 on error
@@ -1442,7 +1475,7 @@ for vm-wide capabilities.
 ---------------------
 
 :Capability: KVM_CAP_MP_STATE
-:Architectures: x86, s390, arm64, riscv
+:Architectures: x86, s390, arm64, riscv, loongarch
 :Type: vcpu ioctl
 :Parameters: struct kvm_mp_state (out)
 :Returns: 0 on success; -1 on error
@@ -1460,7 +1493,7 @@ Possible values are:
 
    ==========================    ===============================================
    KVM_MP_STATE_RUNNABLE         the vcpu is currently running
-                                 [x86,arm64,riscv]
+                                 [x86,arm64,riscv,loongarch]
    KVM_MP_STATE_UNINITIALIZED    the vcpu is an application processor (AP)
                                  which has not yet received an INIT signal [x86]
    KVM_MP_STATE_INIT_RECEIVED    the vcpu has received an INIT signal, and is
@@ -1516,11 +1549,14 @@ For riscv:
 The only states that are valid are KVM_MP_STATE_STOPPED and
 KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not.
 
+On LoongArch, only the KVM_MP_STATE_RUNNABLE state is used to reflect
+whether the vcpu is runnable.
+
 4.39 KVM_SET_MP_STATE
 ---------------------
 
 :Capability: KVM_CAP_MP_STATE
-:Architectures: x86, s390, arm64, riscv
+:Architectures: x86, s390, arm64, riscv, loongarch
 :Type: vcpu ioctl
 :Parameters: struct kvm_mp_state (in)
 :Returns: 0 on success; -1 on error
@@ -1538,6 +1574,9 @@ For arm64/riscv:
 The only states that are valid are KVM_MP_STATE_STOPPED and
 KVM_MP_STATE_RUNNABLE which reflect if the vcpu should be paused or not.
 
+On LoongArch, only the KVM_MP_STATE_RUNNABLE state is used to reflect
+whether the vcpu is runnable.
+
 4.40 KVM_SET_IDENTITY_MAP_ADDR
 ------------------------------
 
@@ -2839,6 +2878,19 @@ Following are the RISC-V D-extension registers:
   0x8020 0000 0600 0020 fcsr      Floating point control and status register
 ======================= ========= =============================================
 
+LoongArch registers are mapped using the lower 32 bits. The upper 16 bits of
+that is the register group type.
+
+LoongArch csr registers are used to control guest cpu or get status of guest
+cpu, and they have the following id bit patterns::
+
+  0x9030 0000 0001 00 <reg:5> <sel:3>   (64-bit)
+
+LoongArch KVM control registers are used to implement some new defined functions
+such as set vcpu counter or reset vcpu, and they have the following id bit patterns::
+
+  0x9030 0000 0002 <reg:16>
+
 
 4.69 KVM_GET_ONE_REG
 --------------------
-- 
2.27.0


  parent reply	other threads:[~2023-08-31  8:32 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31  8:29 [PATCH v20 00/30] Add KVM LoongArch support Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 01/30] LoongArch: KVM: Add kvm related header files Tianrui Zhao
2023-09-11  4:59   ` Huacai Chen
2023-09-11  9:41     ` zhaotianrui
2023-08-31  8:29 ` [PATCH v20 02/30] LoongArch: KVM: Implement kvm module related interface Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 03/30] LoongArch: KVM: Implement kvm hardware enable, disable interface Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 04/30] LoongArch: KVM: Implement VM related functions Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 05/30] LoongArch: KVM: Add vcpu related header files Tianrui Zhao
2023-09-11  8:07   ` Huacai Chen
2023-09-12  8:26     ` zhaotianrui
2023-08-31  8:29 ` [PATCH v20 06/30] LoongArch: KVM: Implement vcpu create and destroy interface Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 07/30] LoongArch: KVM: Implement vcpu run interface Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 08/30] LoongArch: KVM: Implement vcpu handle exit interface Tianrui Zhao
2023-08-31  8:29 ` [PATCH v20 09/30] LoongArch: KVM: Implement vcpu get, vcpu set registers Tianrui Zhao
2023-09-11  9:03   ` Huacai Chen
2023-09-11 10:03     ` zhaotianrui
2023-09-11 10:13       ` zhaotianrui
2023-09-11 11:49       ` Huacai Chen
2023-09-12  2:41         ` bibo mao
2023-08-31  8:30 ` [PATCH v20 10/30] LoongArch: KVM: Implement vcpu ENABLE_CAP ioctl interface Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 11/30] LoongArch: KVM: Implement fpu related operations for vcpu Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 12/30] LoongArch: KVM: Implement vcpu interrupt operations Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 13/30] LoongArch: KVM: Implement misc vcpu related interfaces Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 14/30] LoongArch: KVM: Implement vcpu load and vcpu put operations Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 15/30] LoongArch: KVM: Implement vcpu status description Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 16/30] LoongArch: KVM: Implement update VM id function Tianrui Zhao
2023-09-11 10:00   ` Huacai Chen
2023-09-11 10:23     ` bibo mao
2023-09-12  3:51       ` Huacai Chen
2023-08-31  8:30 ` [PATCH v20 17/30] LoongArch: KVM: Implement virtual machine tlb operations Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 18/30] LoongArch: KVM: Implement vcpu timer operations Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 19/30] LoongArch: KVM: Implement kvm mmu operations Tianrui Zhao
2023-09-07 19:57   ` WANG Xuerui
2023-09-12  9:42     ` zhaotianrui
2023-08-31  8:30 ` [PATCH v20 20/30] LoongArch: KVM: Implement handle csr excption Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 21/30] LoongArch: KVM: Implement handle iocsr exception Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 22/30] LoongArch: KVM: Implement handle idle exception Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 23/30] LoongArch: KVM: Implement handle gspr exception Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 24/30] LoongArch: KVM: Implement handle mmio exception Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 25/30] LoongArch: KVM: Implement handle fpu exception Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 26/30] LoongArch: KVM: Implement kvm exception vector Tianrui Zhao
2023-08-31  8:30 ` [PATCH v20 27/30] LoongArch: KVM: Implement vcpu world switch Tianrui Zhao
2023-09-07 20:04   ` WANG Xuerui
2023-09-12  9:55     ` zhaotianrui
2023-08-31  8:30 ` [PATCH v20 28/30] LoongArch: KVM: Enable kvm config and add the makefile Tianrui Zhao
2023-09-07 20:10   ` WANG Xuerui
2023-09-08  1:40     ` Huacai Chen
2023-09-08  1:49       ` bibo mao
2023-09-08  1:54         ` Huacai Chen
2023-09-12  9:47     ` zhaotianrui
2023-09-11  7:30   ` WANG Xuerui
2023-09-12  1:57     ` zhaotianrui
2023-08-31  8:30 ` Tianrui Zhao [this message]
2023-08-31  8:30 ` [PATCH v20 30/30] LoongArch: KVM: Add maintainers for LoongArch KVM Tianrui Zhao
2023-09-11  4:02 ` [PATCH v20 00/30] Add KVM LoongArch support Huacai Chen
2023-09-11  9:34   ` zhaotianrui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230831083020.2187109-30-zhaotianrui@loongson.cn \
    --to=zhaotianrui@loongson.cn \
    --cc=alexander.deucher@amd.com \
    --cc=axboe@kernel.dk \
    --cc=broonie@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@xen0n.name \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=maobibo@loongson.cn \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.