Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1435505ybh; Fri, 13 Mar 2020 01:00:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv6n8CfFUNQn3xE8Db9Yv4HVKVLT6bSh/KqNJeBpdtiVY9ccAR0zkn6Jddwny5EkoBmEN5S X-Received: by 2002:aca:4b56:: with SMTP id y83mr6041467oia.142.1584086446104; Fri, 13 Mar 2020 01:00:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1584086446; cv=pass; d=google.com; s=arc-20160816; b=giT30cizi5gQN0s5hG7rz4xYaITAEYjoquZb7BhqKP2HtsQtud8VtNW4CC7jWQlJDE OSIQcS4lCdE+khHdtX6Ebq4i0WH29e4GlGvgMXOhlY3BfOSQeoeJragQdEkHXJVrgNQj OQ/6lB9hGgiN+taJGF/f7QagqHIZg6M8V4lHwPV9XC9Iz0+hCJB7kVQUkhjZkHN4+6EZ TtzsDi5k6/0DNoqmgvyMOc238LO05sfyeJs1aFBL4j5OpWoSWoxtKk3I0jhnJfVYj01d 3LZQUU9vhDxwE5O78wmGGuHBXFhT4OYaU7SIo9KHzesHcJ/+OgjfwAz76A8e9bEj8J0r UCKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:wdcipoutbound:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :ironport-sdr:dkim-signature; bh=2vOXQx+C9JLoyAFgt5qIjb1eRhF6WVq89Fogo4E4bTM=; b=EBy4+2Mofqe3Y9TBOoAhgt2tIXla7CJ3EjPA9U00sstYGUZk/jnuxbc6KoCkk6XSmV KmP5dWA0j2rnl31wvIY+naa8fQ3Ch1sk6H1saOzkl1NCczTrYI2M0TRlJJjegfRTGGAa E43ivhE8n3lWfB0qx2RS7fi8HGbv/qEm6svlzRoZxdW3o8m/Ap8Mwl3SQIQKJWfzAPXV bdU0VgSrpzLQY7hpdc8/aZe33b+7IYcY/D1UpcZu/rOf8OB27/upwDEieiqi5ZCDzfLg ykF2R0v0Lquedie8Wv/kOrlCx94s9IQIkmKPU1tvvmVRdxQxtUSjsQbYuijFEWDInnRp /opg== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Q5SJtrOj; dkim=pass header.i=@sharedspace.onmicrosoft.com header.s=selector2-sharedspace-onmicrosoft-com header.b=H+UPbcnD; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si2362597oih.95.2020.03.13.01.00.33; Fri, 13 Mar 2020 01:00:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Q5SJtrOj; dkim=pass header.i=@sharedspace.onmicrosoft.com header.s=selector2-sharedspace-onmicrosoft-com header.b=H+UPbcnD; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbgCMH7r (ORCPT + 99 others); Fri, 13 Mar 2020 03:59:47 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:61392 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgCMH7r (ORCPT ); Fri, 13 Mar 2020 03:59:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1584086386; x=1615622386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=LZ0rmvlcrsRtYTA+WIwxeFZ48Ugr+uzrPWZXvUneIfo=; b=Q5SJtrOjYwkyLMU63BaqdRz5IbTzEtdcemJMM7aChmbpgFdS6n7WmbKB eeZVz/2kUpGjKhdmpacU3+8BxMROVKZXg4xrGOOL85VSKDPwFI2f8j8r5 JqAz5y+L72tCT5p4c0tFs5vKLCPq7jxvSwJ2kJdTmZ0NA54zm8Litlx89 Ej/nK9QPneSzOscYjG0Nuhm82fxwBTBARzf2ZM8z/t+JndJcKYTDm9Xdh krwE9V02ceU/Tb47BMwvwqzJLOyFik9rFipTJNB2BXOfYxMd4sBetZwPr 51b9545wkbNggBTm9C8KKJ14Zlnh+JcUd1WnJP9WEi+FrhbOO1vMOwTEZ g==; IronPort-SDR: 99xlGEQ5UXN2K0qvnG03coV9W+i1Gjp4D/Wx9snTZOXFqSTQ4ukr1X8OdKoizMd8PdX3WL5R1T at+e9QXn0MZItD1Hp+ae3GR9QFaTLK9P49Obs8ZYJ3eDs4+iAuUomsUYQUOzVTADYrKiFtkSPS EE9xw+dBH944xrZxM/nhKBmA+dpZKex/EfhgNTrYRORsSnqRfbhW63UjV36TeN4lYgcKY2XwL/ 4XQAbaoffCn07wQE5HdIYBvnyXjWdSSuExQwhE2ruCszwk0PH6gZ69p/Z28J3aNNFjLJl3oQd1 j44= X-IronPort-AV: E=Sophos;i="5.70,547,1574092800"; d="scan'208";a="240664595" Received: from mail-dm6nam11lp2168.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.168]) by ob1.hgst.iphmx.com with ESMTP; 13 Mar 2020 15:59:44 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S1pVIarC434Yq8X/ehzcfyy2l052Tz4CxmmNKSCTV4ocSZM2/P9bj12w9SE/09zGpKm0bFF8+mTq96vi9y5kziyBrclpE6bngOcyy5iACIIwKcyiH/+B2IXg1o1aHf3eeG5Mu+ETNeDNra3vzO3J1xRYQwUShgv0uzyx74dWNknN9F6Z8QsTsb/vd0WxpL/EWhaHWIQV2eW64vKTV7b1B4gqkf0biEeBTMCC7TGb9ynh6UQ/xXF66Ge8xGtriVllOYCg0P+weJvMLp2OFcqMCC8skGSxkWwmc1MHVlDvz6Kp82dms1hr9tzmsp/T6o51Oj3CXNgwHfuPms6Z44fE5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2vOXQx+C9JLoyAFgt5qIjb1eRhF6WVq89Fogo4E4bTM=; b=Oz17bdS3sh+iVtBoA9IeHcW9b8R0PYYpfeG79z+2Vtp/JJaCcf7IPcLTuQaSbTqD1NRl5C+VQ7JTM6Qrfe5DKUDbJzfvtwhhP+oWFjKQu5DqEd8RAYXVX7DGsZPX8lB8bT0IGBrZJmnAY18mj9iTBPC5nUO3hW5pOPk0lB+GAOHVADg8QQ7v78ZPClsQkiToWMCfs7c27ctMSMGAp70TzuI5EUJM4FJmGDUG2MAx/qkXzFyWMr9+AfuaveOX2R6f3njHZuGbwNs9M1g9rgBGIQ5tclZcwBIHHqlROiBrA/b56XqPpRt7RTuBkML5IOUmyQqr3lUpq7P06tpRXiudDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2vOXQx+C9JLoyAFgt5qIjb1eRhF6WVq89Fogo4E4bTM=; b=H+UPbcnDPXi4BDGKBlVqCPlWHLIsrzQZKlknXdmYabmUes4kpicNz1rKGMAxA3URGvYufryEbt3nx7/bZjj21kSgpWe5R8xO30jEY60oY/LnuJ5zfC1BeONIjtSm/FPUUpyclfuZ8klh+VPxbc6zws/QQBbnCMYdN0j8xlkywfo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; Received: from MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) by MN2PR04MB6944.namprd04.prod.outlook.com (2603:10b6:208:1ed::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.14; Fri, 13 Mar 2020 07:59:42 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::159d:10c9:f6df:64c8]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::159d:10c9:f6df:64c8%6]) with mapi id 15.20.2814.018; Fri, 13 Mar 2020 07:59:42 +0000 From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Albert Ou , Paolo Bonzini , Radim K Cc: Alexander Graf , Atish Patra , Alistair Francis , Damien Le Moal , Christoph Hellwig , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH v11 19/20] RISC-V: KVM: Document RISC-V specific parts of KVM API Date: Fri, 13 Mar 2020 13:21:30 +0530 Message-Id: <20200313075131.69837-20-anup.patel@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200313075131.69837-1-anup.patel@wdc.com> References: <20200313075131.69837-1-anup.patel@wdc.com> Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0057.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::19) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (1.39.129.91) by MA1PR0101CA0057.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.14 via Frontend Transport; Fri, 13 Mar 2020 07:59:34 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [1.39.129.91] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4da4aea4-9485-4d45-7d08-08d7c7247c7c X-MS-TrafficTypeDiagnostic: MN2PR04MB6944: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 034119E4F6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4636009)(39860400002)(376002)(136003)(346002)(396003)(366004)(199004)(26005)(4326008)(44832011)(55016002)(1076003)(8936002)(478600001)(86362001)(36756003)(66556008)(16526019)(66946007)(956004)(66476007)(186003)(30864003)(2616005)(316002)(7416002)(966005)(6666004)(1006002)(110136005)(8886007)(8676002)(2906002)(81166006)(81156014)(5660300002)(54906003)(52116002)(7696005)(36456003)(42976004);DIR:OUT;SFP:1102;SCL:1;SRVR:MN2PR04MB6944;H:MN2PR04MB6061.namprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6tmxt5TaWIUSt9KrBRQ8FN1qRUTRZEurmn1w4CYtP7OmuMH+w51X39H1SpBMhlBjvfUmGnkm8Wg1WuGn0V3aGI9ziUhPOhc+mZIU/IZbh71iMzhlYWXosLNXaXk55jl1T8F+orao598BVwPX/quwaeQO1k6mVqSdLqOHPR1ruZ2IeyBqveiZFW5yuDJIeMQNHH91+iaPgma27KVb0Wv6/I/ARazqrmjKxIGJpyp3BfFYDDb3zl7IUC9fQbwiME0/t9ef92d/ccE7milxg4qIYyvOXNO2BPBtDuF+LqkRaLGbwy40mEwAGKnVDLii/KtUVKShkbOTI/VOTbckHuPgbgk2Y2+1OukgszO8ES8Oc9/VGa3Qpf7PrWAyI2SvBpFgYFleF05aVHMneOI1Lf1SJyXpkxYonFN/jh5X1jgQ8Ae/+Te2E0R5zOdu0+9dt6oGrIQLB1g1m/fCd7V4a+GlieoDlerozW/Eymx3ENL7mqgJwRTyxEJf8ecD98a1QejURLAi2bP/ZkQRqvi9ah2GIU8K6j/wWRG7zB1nVPgUfSxU3atXOHk4MYZdtrzbhhwh0GUmTE8MctQyYyVrqKdbLFstXfrroTjZZsNsmvhc3BM= X-MS-Exchange-AntiSpam-MessageData: Iip2jBrls2vZSy9ZwwIN834qwMk436PBdwxonA3zZUSUxXFnY9q3iAZkVH5e3gvYnkbabX6LKeemkLm8Sb/TMUXxTs0LizF3prfQQs8cLfEFFvZ2K8RwizLQKMn/aPKlMOZQ9dp16Uv9hGHSyIsuEg== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4da4aea4-9485-4d45-7d08-08d7c7247c7c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2020 07:59:42.3844 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T26iWhiVwb4Qxn8SUzqacCCzgjhVneRX/r0qBzMlMw2itPsc9n650Zwuoqp4ffmXx6NC8fs/6ZwrZpq0X5m0bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6944 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document RISC-V specific parts of the KVM API, such as: - The interrupt numbers passed to the KVM_INTERRUPT ioctl. - The states supported by the KVM_{GET,SET}_MP_STATE ioctls. - The registers supported by the KVM_{GET,SET}_ONE_REG interface and the encoding of those register ids. - The exit reason KVM_EXIT_RISCV_SBI for SBI calls forwarded to userspace tool. CC: Jonathan Corbet CC: linux-doc@vger.kernel.org Signed-off-by: Anup Patel --- Documentation/virt/kvm/api.rst | 193 +++++++++++++++++++++++++++++++-- 1 file changed, 184 insertions(+), 9 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index ebd383fba939..20d78c6e0a1a 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -513,7 +513,7 @@ translation mode. ------------------ :Capability: basic -:Architectures: x86, ppc, mips +:Architectures: x86, ppc, mips, riscv :Type: vcpu ioctl :Parameters: struct kvm_interrupt (in) :Returns: 0 on success, negative on failure. @@ -582,6 +582,23 @@ interrupt number dequeues the interrupt. This is an asynchronous vcpu ioctl and can be invoked from any thread. +RISC-V: +^^^^^^^ + +Queues an external interrupt to be injected into the virutal CPU. This ioctl +is overloaded with 2 different irq values: + +a) KVM_INTERRUPT_SET + + This sets external interrupt for a virtual CPU and it will receive + once it is ready. + +b) KVM_INTERRUPT_UNSET + + This clears pending external interrupt for a virtual CPU. + +This is an asynchronous vcpu ioctl and can be invoked from any thread. + 4.17 KVM_DEBUG_GUEST -------------------- @@ -1360,7 +1377,7 @@ for vm-wide capabilities. --------------------- :Capability: KVM_CAP_MP_STATE -:Architectures: x86, s390, arm, arm64 +:Architectures: x86, s390, arm, arm64, riscv :Type: vcpu ioctl :Parameters: struct kvm_mp_state (out) :Returns: 0 on success; -1 on error @@ -1377,7 +1394,8 @@ uniprocessor guests). Possible values are: ========================== =============================================== - KVM_MP_STATE_RUNNABLE the vcpu is currently running [x86,arm/arm64] + KVM_MP_STATE_RUNNABLE the vcpu is currently running + [x86,arm/arm64,riscv] 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 @@ -1386,7 +1404,7 @@ Possible values are: is waiting for an interrupt [x86] KVM_MP_STATE_SIPI_RECEIVED the vcpu has just received a SIPI (vector accessible via KVM_GET_VCPU_EVENTS) [x86] - KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm/arm64] + KVM_MP_STATE_STOPPED the vcpu is stopped [s390,arm/arm64,riscv] KVM_MP_STATE_CHECK_STOP the vcpu is in a special error state [s390] KVM_MP_STATE_OPERATING the vcpu is operating (running or halted) [s390] @@ -1398,8 +1416,8 @@ On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel irqchip, the multiprocessing state must be maintained by userspace on these architectures. -For arm/arm64: -^^^^^^^^^^^^^^ +For arm/arm64/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. @@ -1408,7 +1426,7 @@ KVM_MP_STATE_RUNNABLE which reflect if the vcpu is paused or not. --------------------- :Capability: KVM_CAP_MP_STATE -:Architectures: x86, s390, arm, arm64 +:Architectures: x86, s390, arm, arm64, riscv :Type: vcpu ioctl :Parameters: struct kvm_mp_state (in) :Returns: 0 on success; -1 on error @@ -1420,8 +1438,8 @@ On x86, this ioctl is only useful after KVM_CREATE_IRQCHIP. Without an in-kernel irqchip, the multiprocessing state must be maintained by userspace on these architectures. -For arm/arm64: -^^^^^^^^^^^^^^ +For arm/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. @@ -2538,6 +2556,144 @@ following id bit patterns:: 0x7020 0000 0003 02 <0:3> +RISC-V registers are mapped using the lower 32 bits. The upper 8 bits of +that is the register group type. + +RISC-V config registers are meant for configuring a Guest VCPU and it has +the following id bit patterns:: + + 0x8020 0000 01 (32bit Host) + 0x8030 0000 01 (64bit Host) + +Following are the RISC-V config registers: + +======================= ========= ============================================= + Encoding Register Description +======================= ========= ============================================= + 0x80x0 0000 0100 0000 isa ISA feature bitmap of Guest VCPU +======================= ========= ============================================= + +The isa config register can be read anytime but can only be written before +a Guest VCPU runs. It will have ISA feature bits matching underlying host +set by default. + +RISC-V core registers represent the general excution state of a Guest VCPU +and it has the following id bit patterns:: + + 0x8020 0000 02 (32bit Host) + 0x8030 0000 02 (64bit Host) + +Following are the RISC-V core registers: + +======================= ========= ============================================= + Encoding Register Description +======================= ========= ============================================= + 0x80x0 0000 0200 0000 regs.pc Program counter + 0x80x0 0000 0200 0001 regs.ra Return address + 0x80x0 0000 0200 0002 regs.sp Stack pointer + 0x80x0 0000 0200 0003 regs.gp Global pointer + 0x80x0 0000 0200 0004 regs.tp Task pointer + 0x80x0 0000 0200 0005 regs.t0 Caller saved register 0 + 0x80x0 0000 0200 0006 regs.t1 Caller saved register 1 + 0x80x0 0000 0200 0007 regs.t2 Caller saved register 2 + 0x80x0 0000 0200 0008 regs.s0 Callee saved register 0 + 0x80x0 0000 0200 0009 regs.s1 Callee saved register 1 + 0x80x0 0000 0200 000a regs.a0 Function argument (or return value) 0 + 0x80x0 0000 0200 000b regs.a1 Function argument (or return value) 1 + 0x80x0 0000 0200 000c regs.a2 Function argument 2 + 0x80x0 0000 0200 000d regs.a3 Function argument 3 + 0x80x0 0000 0200 000e regs.a4 Function argument 4 + 0x80x0 0000 0200 000f regs.a5 Function argument 5 + 0x80x0 0000 0200 0010 regs.a6 Function argument 6 + 0x80x0 0000 0200 0011 regs.a7 Function argument 7 + 0x80x0 0000 0200 0012 regs.s2 Callee saved register 2 + 0x80x0 0000 0200 0013 regs.s3 Callee saved register 3 + 0x80x0 0000 0200 0014 regs.s4 Callee saved register 4 + 0x80x0 0000 0200 0015 regs.s5 Callee saved register 5 + 0x80x0 0000 0200 0016 regs.s6 Callee saved register 6 + 0x80x0 0000 0200 0017 regs.s7 Callee saved register 7 + 0x80x0 0000 0200 0018 regs.s8 Callee saved register 8 + 0x80x0 0000 0200 0019 regs.s9 Callee saved register 9 + 0x80x0 0000 0200 001a regs.s10 Callee saved register 10 + 0x80x0 0000 0200 001b regs.s11 Callee saved register 11 + 0x80x0 0000 0200 001c regs.t3 Caller saved register 3 + 0x80x0 0000 0200 001d regs.t4 Caller saved register 4 + 0x80x0 0000 0200 001e regs.t5 Caller saved register 5 + 0x80x0 0000 0200 001f regs.t6 Caller saved register 6 + 0x80x0 0000 0200 0020 mode Privilege mode (1 = S-mode or 0 = U-mode) +======================= ========= ============================================= + +RISC-V csr registers represent the supervisor mode control/status registers +of a Guest VCPU and it has the following id bit patterns:: + + 0x8020 0000 03 (32bit Host) + 0x8030 0000 03 (64bit Host) + +Following are the RISC-V csr registers: + +======================= ========= ============================================= + Encoding Register Description +======================= ========= ============================================= + 0x80x0 0000 0300 0000 sstatus Supervisor status + 0x80x0 0000 0300 0001 sie Supervisor interrupt enable + 0x80x0 0000 0300 0002 stvec Supervisor trap vector base + 0x80x0 0000 0300 0003 sscratch Supervisor scratch register + 0x80x0 0000 0300 0004 sepc Supervisor exception program counter + 0x80x0 0000 0300 0005 scause Supervisor trap cause + 0x80x0 0000 0300 0006 stval Supervisor bad address or instruction + 0x80x0 0000 0300 0007 sip Supervisor interrupt pending + 0x80x0 0000 0300 0008 satp Supervisor address translation and protection +======================= ========= ============================================= + +RISC-V timer registers represent the timer state of a Guest VCPU and it has +the following id bit patterns:: + + 0x8030 0000 04 + +Following are the RISC-V timer registers: + +======================= ========= ============================================= + Encoding Register Description +======================= ========= ============================================= + 0x8030 0000 0400 0000 frequency Time base frequency (read-only) + 0x8030 0000 0400 0001 time Time value visible to Guest + 0x8030 0000 0400 0002 compare Time compare programmed by Guest + 0x8030 0000 0400 0003 state Time compare state (1 = ON or 0 = OFF) +======================= ========= ============================================= + +RISC-V F-extension registers represent the single precision floating point +state of a Guest VCPU and it has the following id bit patterns:: + + 0x8020 0000 05 + +Following are the RISC-V F-extension registers: + +======================= ========= ============================================= + Encoding Register Description +======================= ========= ============================================= + 0x8020 0000 0500 0000 f[0] Floating point register 0 + ... + 0x8020 0000 0500 001f f[31] Floating point register 31 + 0x8020 0000 0500 0020 fcsr Floating point control and status register +======================= ========= ============================================= + +RISC-V D-extension registers represent the double precision floating point +state of a Guest VCPU and it has the following id bit patterns:: + + 0x8020 0000 06 (fcsr) + 0x8030 0000 06 (non-fcsr) + +Following are the RISC-V D-extension registers: + +======================= ========= ============================================= + Encoding Register Description +======================= ========= ============================================= + 0x8030 0000 0600 0000 f[0] Floating point register 0 + ... + 0x8030 0000 0600 001f f[31] Floating point register 31 + 0x8020 0000 0600 0020 fcsr Floating point control and status register +======================= ========= ============================================= + 4.69 KVM_GET_ONE_REG -------------------- @@ -5088,6 +5244,25 @@ Note that KVM does not skip the faulting instruction as it does for KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state if it decides to decode and emulate the instruction. +:: + + /* KVM_EXIT_RISCV_SBI */ + struct { + unsigned long extension_id; + unsigned long function_id; + unsigned long args[6]; + unsigned long ret[2]; + } riscv_sbi; +If exit reason is KVM_EXIT_RISCV_SBI then it indicates that the VCPU has +done a SBI call which is not handled by KVM RISC-V kernel module. The details +of the SBI call are available in 'riscv_sbi' member of kvm_run structure. The +'extension_id' field of 'riscv_sbi' represents SBI extension ID whereas the +'function_id' field represents function ID of given SBI extension. The 'args' +array field of 'riscv_sbi' represents parameters for the SBI call and 'ret' +array field represents return values. The userspace should update the return +values of SBI call before resuming the VCPU. For more details on RISC-V SBI +spec refer, https://github.com/riscv/riscv-sbi-doc. + :: /* Fix the size of the union. */ -- 2.17.1