Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp844702rwd; Thu, 15 Jun 2023 02:55:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HYF8RNTZMFr0+Yj9ojsZ2XDrRD2ybz4MAdKYxArHpRp7xIdsYY9my8o/uKnXeX+VPgNgs X-Received: by 2002:a17:907:1c97:b0:973:ff4d:d01e with SMTP id nb23-20020a1709071c9700b00973ff4dd01emr19066838ejc.31.1686822929621; Thu, 15 Jun 2023 02:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686822929; cv=none; d=google.com; s=arc-20160816; b=DOoxmp+Dp4AI3tPeeaTwjMyyoEGQusb9NHxEC/6vwpi7H0gfAvVX+alV3wUBmTKxpd GaBiCk6EPCHCPsAEb3b6okrC51yJza4O0MCodx8/gbimWsxJrlPWujbG4/6OZTgLYHmg YZOSi7zT+6paOpkPeMSNZdWYuHs3WGKgxUF3qe9OelP7V8cfvGARnTtXs6XocJXDCzXY Xlji8RsrUOoghcFSdCS1jpfcRKj1D+UbNAZNSfUWYZN5w8BHKRl5oTua/tVyvv8A86WJ RshcjlWUh0k2QTNLXETmL0q2uhgmOlJXc6hwV6N62foSXs9gpss7SVVHLXrCzjqXWE6q TdKQ== 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=JElcyiL3SGahHuZRnDZpgDiEsPvS4cd27NAWFKkar40=; b=Wu2uAKVR+iGJFI2HMl+CiXM5esVHUChpouN3Dw3JWByeX3ZTO42nVm1fF/JtLPez/2 XYy0I0Bmr5Xay5rVdpFEg93kT4eHSsTOpk0OJ9zmODXCfNK96cuCPF0CU8W3CGhIGBjj MMoArcUgKTwTWuuagB2UW0QmNX4/GI8/CpZLJL8qc2yM2gjKQHyPdyP0eHAOaDA7iYhQ Tw5d44qtYz/SdVY1i/g/zakrzNbUjMA+oqVVAH82SqDD6VqdwDmvCFyQqC1vqn8kDpYG iCBBbef+je3CWVsk/O4mypqdrJ61YwuWHkC0gC4OthAm7GRaJYovRsaBX2gyRzDqxdcY yiew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u8g8Ozh3; 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 y5-20020a1709063a8500b0096f504af253si6595036ejd.677.2023.06.15.02.55.05; Thu, 15 Jun 2023 02:55:29 -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=u8g8Ozh3; 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 S243365AbjFOJmZ (ORCPT + 99 others); Thu, 15 Jun 2023 05:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241720AbjFOJmW (ORCPT ); Thu, 15 Jun 2023 05:42:22 -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 5381D1A3; Thu, 15 Jun 2023 02:42:21 -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 C874D62A6B; Thu, 15 Jun 2023 09:42:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BE72C433D9; Thu, 15 Jun 2023 09:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686822140; bh=XQuGQJ3NoUrSQwNFP59JJLdxojYQ1TBivS0WT8/w20M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=u8g8Ozh3mE2Snbs1cwUSb+RzROAQ6VDZetn74FhW+Lvt6kK7tuQnxhXI1q57lMD2r HjDbmJrSNVgR8BdXSaF25zqfgUXCj89a1Dw1oMD26FGuC1CAPYf2MCY0KD2ODAghM5 Qc9++SJw+7dFtVAIW+Fhcya1X9t6JJsz0wPmfcmakfCryJs/u/0XMZKwmJj87l23o8 rn4/Hj+TiJimGzHM+tbpdxFNWfYKlPcQmGEGhxzEQI1NbsYeeZCL8VF+0sWbQGiUwg DWy7oRzztq2Gy8xA2U9iTihhUfAniq596JyRQB19gnnlL/PJsKq0q0+H+R2oW8gHtu 65gdoJ4b7D0bw== Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5151934a4e3so11278570a12.1; Thu, 15 Jun 2023 02:42:20 -0700 (PDT) X-Gm-Message-State: AC+VfDzn2iSVkbtmzimQzbF7RTxc3UxPzbWTg0CCh98bdaGCP2WanLCu 4ECP/v4WA5tBN27uzNy+iQzZv6ddbtPdKuZSInY= X-Received: by 2002:aa7:d358:0:b0:514:9423:65a5 with SMTP id m24-20020aa7d358000000b00514942365a5mr12355526edr.19.1686822138291; Thu, 15 Jun 2023 02:42:18 -0700 (PDT) MIME-Version: 1.0 References: <20230609090832.2131037-1-zhaotianrui@loongson.cn> <20230609090832.2131037-30-zhaotianrui@loongson.cn> In-Reply-To: <20230609090832.2131037-30-zhaotianrui@loongson.cn> From: Huacai Chen Date: Thu, 15 Jun 2023 17:42:05 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v13 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 Hi, Tianrui, On Fri, Jun 9, 2023 at 5:09=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 | 71 +++++++++++++++++++++++++++++----- > 1 file changed, 62 insertions(+), 9 deletions(-) > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.= rst > index add067793b90..ad8e13eab48d 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -416,6 +416,12 @@ Reads the general purpose registers from the vcpu. > __u64 pc; > }; > > + /* LoongArch */ > + struct kvm_regs { Add a " /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */" line as others here? > + unsigned long gpr[32]; > + unsigned long pc; > + }; > + > > 4.12 KVM_SET_REGS > ----------------- > @@ -506,7 +512,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 +598,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 +751,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 +760,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 +775,22 @@ Reads the floating point state from the vcpu. > __u32 pad2; > }; > > + /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */ > + struct kvm_fpu { > + __u32 fcsr; > + __u32 none; Maybe use pad1 as x86 is better. Huacai > + __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,16 @@ Writes the floating point state to the vcpu. > __u32 pad2; > }; > > + /* LoongArch: for KVM_GET_FPU and KVM_SET_FPU */ > + struct kvm_fpu { > + __u32 fcsr; > + __u32 none; > + __u64 fcc; > + struct kvm_fpureg { > + __u64 val64[4]; > + }fpr[32]; > + }; > + > > 4.24 KVM_CREATE_IRQCHIP > ----------------------- > @@ -1387,7 +1421,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 +1476,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 +1494,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 +1550,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 +1575,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 +2879,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 > >