Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6176285rwd; Mon, 19 Jun 2023 03:37:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5sAOMRipeuTNwtZWso1StWdnfx1N/azBGhliPUySJrJZZuhKUnhb2klXwvXdGaC02VMarM X-Received: by 2002:a05:6358:1a94:b0:128:55b:df76 with SMTP id gm20-20020a0563581a9400b00128055bdf76mr3472905rwb.8.1687171025056; Mon, 19 Jun 2023 03:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687171025; cv=none; d=google.com; s=arc-20160816; b=B+oGpq0gHrbE4Yybym1hLcN/bRHaza3zbaXi4dlSXvxpN4gHazfCnGR7NYAzttyebu akFD+wuq3MT4cNTCp0WEDtdGDrHUNaa8MFRxvnK6PYlL5ucvlmCobHV8nsNglhkHy6hy 0hOReS0DV2Q7EuhIZxtZ3TsKLYZqmtmPCrA9MCPP9BggtE/4koYa8l5mYfOv4KS1SZgz 4ibFyYgVbR8JUXX827mnw4uRsBhPOJzXOAUmR1h/ESkDj7ueiEgEhGq8T0cStdFi/bpV +Mwh9SZdF+2e7mASPYkPBVlGP2DQukp2qi+z6WponvXM32kMk6G6RIwTWKS1v+iy1FrN T1Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=eldaLOFNAyV1xs5Xgt6o6YA6D2/tew6VZu7uCy3QLdA=; b=qDYzBw5QwV3H57t+KyjC0eE1XN/OoW615KWLygnBBvkaKN+3pCMAhzulpWfekJh5yj mZM2i+x7V2AIHJd7oCicR55I6NT9rh8IG5g52GAXluCh6XQ+NvyrL31zLqlVPjwF9UpB DfROKd3GTdqoEcCOTMEGA50rDJhMPCSAgsEBxj7ojx7Lz+wNlzWcZ0VGkK+iznwCaovJ 2+UWjvKLOmZwkiwUl5m+AZsHXmZohOLeawph4jfu5H1rqm870uKUc2mtwJ7CBFHteq6H 9At/He8nM3RKPEHe5i7WcnI3T1GmoNJG9uhaHaRtDHzk1YdXESJTY8voi7ZCu75iJNQY epzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7TO71ss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a63af11000000b00553d904c946si623919pge.514.2023.06.19.03.36.49; Mon, 19 Jun 2023 03:37:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7TO71ss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbjFSK0j (ORCPT + 99 others); Mon, 19 Jun 2023 06:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbjFSK03 (ORCPT ); Mon, 19 Jun 2023 06:26:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64FD013D; Mon, 19 Jun 2023 03:26:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DEC4C60B3E; Mon, 19 Jun 2023 10:26:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D02FC43391; Mon, 19 Jun 2023 10:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687170387; bh=YzS+7JT5JGD5OnwOktHBbPjec4tNOdx49qt9Nw4Nckk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=M7TO71ssQ+Oh0HjrZKHBlEeR+7P40JKK7smU2a4nEr+pKfBh3TyjpnBV8/Vpkm40z rokfithS+EAPdyBUrXBlZYpIj9yLpRfJPR/bE87xF+JTS6MSttJlJulKqYRBVO0XKW JsZgqU31LXJiQRb1nW0ZzyE9Af6Zy5K4+5uRZdObebkHAqN6a0lRQv2jemgSKCeXA2 cgSsGbxK1vqZYJgWG0sr5pG9Hj/VG83ZqcLKLmJfxvdt8XP2z1kw2KS3dfyE0ibqyn L9exxlfM1Vx/jUF+feGrAGqDkIujNSdpQIF2YGGgyqlA+5qGas3E9ioYOvgfsrMxKi 5Goj7/UhMyNpA== Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-51a2fa4a45eso4237944a12.0; Mon, 19 Jun 2023 03:26:27 -0700 (PDT) X-Gm-Message-State: AC+VfDxzVLqEiMTCMvOWULP7K+OegssXs2M3XBEdw7bLBeFXb/BIl1Os XpChg1ht41D9S9VSQWk2hK7OBVFt8m5KA0CWfIE= X-Received: by 2002:aa7:cf19:0:b0:518:922a:bc38 with SMTP id a25-20020aa7cf19000000b00518922abc38mr6816336edy.2.1687170385462; Mon, 19 Jun 2023 03:26:25 -0700 (PDT) MIME-Version: 1.0 References: <20230619083255.3841777-1-zhaotianrui@loongson.cn> <20230619083255.3841777-30-zhaotianrui@loongson.cn> In-Reply-To: <20230619083255.3841777-30-zhaotianrui@loongson.cn> From: Huacai Chen Date: Mon, 19 Jun 2023 18:26:13 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v14 29/30] LoongArch: KVM: Supplement kvm document about LoongArch-specific part To: Tianrui Zhao Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , WANG Xuerui , Greg Kroah-Hartman , loongarch@lists.linux.dev, Jens Axboe , Mark Brown , Alex Deucher , Oliver Upton , maobibo@loongson.cn, Xi Ruoyao , tangyouling@loongson.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reviewed-by: Huacai Chen On Mon, Jun 19, 2023 at 4:34=E2=80=AFPM Tianrui Zhao wrote: > > 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. > > Signed-off-by: Tianrui Zhao > --- > 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 add067793b90..0bae97c63156 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 nega= tive > +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: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > 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 (A= P) > which has not yet received an INIT sign= al [x86] > KVM_MP_STATE_INIT_RECEIVED the vcpu has received an INIT signal, a= nd 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 regi= ster > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > +LoongArch registers are mapped using the lower 32 bits. The upper 16 bit= s of > +that is the register group type. > + > +LoongArch csr registers are used to control guest cpu or get status of g= uest > +cpu, and they have the following id bit patterns:: > + > + 0x9030 0000 0001 00 (64-bit) > + > +LoongArch KVM control registers are used to implement some new defined f= unctions > +such as set vcpu counter or reset vcpu, and they have the following id b= it patterns:: > + > + 0x9030 0000 0002 > + > > 4.69 KVM_GET_ONE_REG > -------------------- > -- > 2.39.1 >