Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4618359ybi; Tue, 30 Jul 2019 05:16:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyk0hR6yWt5b2pisknqOVqKRjxX3vExkPdYzsbMJZw/n37WcfLRK9lKWbU5SD5/iDOs0khm X-Received: by 2002:aa7:9713:: with SMTP id a19mr23652479pfg.64.1564489018637; Tue, 30 Jul 2019 05:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564489018; cv=none; d=google.com; s=arc-20160816; b=urOgL9o4ZbFS31ljq7X7OF4nJrc2bCaB69NxRfvPNqqigUqMvLPmTRZqyt+7CIDp// NYIUbX6IVimZz/Wv4DbHJoQsulvcWmQD/8eZFycoGmZvp5/OgA1FdhuwTdirzkRrTi1J Ud4sVktxR/8lbwiAeql0HRotKjQB0TEQqmDQVR/5RJ8iY1ThK+4z6yXSFiDut3QW8Kdd +GQDN7SyYfVSUauqR44RExMbWSRqvAkihwlBoU6YH5MZF9NNRKbMLaAZCvAJ+wHOV68I wlpS7H2gbjwPJh5twreyE7dPjOsXsHsp2MZGnx9e1gZPcM0CU+vp553WpV0CzwyXpSAz 5qCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DSo219uBBQuUIUjoxpKujZtQ/5w8YP4pzpQJT3D8aBA=; b=ss4tw3v/91qXMQn2x9laglxnzSX1kowQwPE0Z6v44WZCq/VaTmdRDKjDk8N695y9Mb 0Eb9nhbIv6ngy3Jp+sBRKP9x8gAazc1I03pI1znxDTfHqNlHaEht48s+JOBMFGg/TQZo SoilsegAuVsFIBgDQWfsUXmtCHvDFeE1bR+zSefdaXpAK+39zxzF7Lte7aOICx9VYBYY ycgXkQUKEVxVat96gXP2JubIrCR3sJ/iUPMewJ/Zo2CbZzHythCbKa6Ty2J41ehiHGEp xfmXdxZD0hCL526Ed4fyScQPxz2KUwNMX9cC+EBA4KIWpk0mbqfvBMTXj+tRXzuFL28R Y6UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=gbw6Cwke; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si30666904pgq.372.2019.07.30.05.16.44; Tue, 30 Jul 2019 05:16:58 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=gbw6Cwke; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730921AbfG3LqJ (ORCPT + 99 others); Tue, 30 Jul 2019 07:46:09 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45785 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730893AbfG3LqH (ORCPT ); Tue, 30 Jul 2019 07:46:07 -0400 Received: by mail-wr1-f67.google.com with SMTP id f9so65397755wre.12 for ; Tue, 30 Jul 2019 04:46:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DSo219uBBQuUIUjoxpKujZtQ/5w8YP4pzpQJT3D8aBA=; b=gbw6CwkeXhENGj0Eco2ek5ibwxV16dRDV7am21QurDDO6eOhOkVzbupEo0vU5bjnX8 wooptB/qSlORBPn6AJO9d6w6OTdp8aKbkrTjrp8IMloxRKPXN2yYh47vKeAN/CFaSZYc Wv4D9akzJgzNvlbW6kCYgSG5YfrJLKMHeK5qJ5Os6kkfd8HRUesS8DW3VJif/ZhFLgVa ISCTcC/JSf8tTK7eXzEfjoBsWfG2JmxjnSA0s37YubJ9mISX5km8dbVKEIjFQRlWhxxD c/GVRcN0F/txPzvFKgC/LRk0YOagBkFUvHIj1KabmrGucdZCwu0ckNAkGrLyj6NzYnMs 9YXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DSo219uBBQuUIUjoxpKujZtQ/5w8YP4pzpQJT3D8aBA=; b=JAYwBEbxed7I8r+oXrFSrkR/R8U2HUudlb0cKcyCGIPLwpuNVc2FSrhNL6femQMmJC KaXnC1EhDg4Yh4ea5dBPykdYl0J8m15vCJ45vOhr9SVm8Cs0TnKPtT+MNdXgVrtO3xlh MkqapCvSkQiIhnRxysKV9nzleovCkExXeRepAPLvH64zp73vuxb2QD0aSGrHqxDkp4JF XQ7fZUAP9mju6AAXWGeIJ0dSfD5/inPB3gF2eKKl+f6K2MAZdPqFe93v6OPb4O//dfhF yvhuJYyVMZ8KnLceZCNtS45gtD6JqxQGLUINY6f8pFLGyi2isIsWNJNC2UVic8UBeDM0 H0kg== X-Gm-Message-State: APjAAAWCAmYwDYmKQ0jcuvS/9hptXTBGREr9aZcDpCvVoiqIqy0bB8zA vMJA5lPtW4qs4AC5AiAr+LHFMVDfdMtq5b3iawU= X-Received: by 2002:a5d:6284:: with SMTP id k4mr94957352wru.179.1564487165402; Tue, 30 Jul 2019 04:46:05 -0700 (PDT) MIME-Version: 1.0 References: <20190729115544.17895-1-anup.patel@wdc.com> <20190729115544.17895-5-anup.patel@wdc.com> <2de10efc-56f8-ff47-ed69-7e471a099c80@redhat.com> In-Reply-To: <2de10efc-56f8-ff47-ed69-7e471a099c80@redhat.com> From: Anup Patel Date: Tue, 30 Jul 2019 17:15:53 +0530 Message-ID: Subject: Re: [RFC PATCH 04/16] RISC-V: KVM: Implement VCPU create, init and destroy functions To: Paolo Bonzini Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Radim K , Daniel Lezcano , Thomas Gleixner , Atish Patra , Alistair Francis , Damien Le Moal , Christoph Hellwig , "kvm@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 30, 2019 at 3:46 PM Paolo Bonzini wrote: > > On 30/07/19 10:48, Paolo Bonzini wrote: > > On 29/07/19 13:56, Anup Patel wrote: > >> + cntx->hstatus |= HSTATUS_SP2V; > >> + cntx->hstatus |= HSTATUS_SP2P; > > IIUC, cntx->hstatus's SP2P bit contains the guest's sstatus.SPP bit? > > Nevermind, that was also a bit confused. The guest's sstatus.SPP is in > vsstatus. The pseudocode for V-mode switch is > > SRET: > V = hstatus.SPV (1) > MODE = sstatus.SPP > hstatus.SPV = hstatus.SP2V > sstatus.SPP = hstatus.SP2P > hstatus.SP2V = 0 > hstatus.SP2P = 0 > ... > > trap: > hstatus.SP2V = hstatus.SPV > hstatus.SP2P = sstatus.SPP > hstatus.SPV = V (1) > sstatus.SPP = MODE > V = 0 > MODE = 1 > Yes, this kind of pseudo-code are not explicitly specified in the RISC-V spec. The RISC-V formal model is supposed to cover this kind of detailed HW state transition. > so: > > 1) indeed we need SP2V=SPV=1 when entering guest mode > > 2) sstatus.SPP contains the guest mode > > 3) SP2P doesn't really matter for KVM since it never goes to VS-mode > from an interrupt handler, so if my reasoning is correct I'd leave it > clear, but I guess it's up to you whether to set it or not. Yes, SP2P does not matter but we set it to 1 here so that from Guest perspective it seems we were in S-mode previously. Regards, Anup