lkml.org 
[lkml]   [2019]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC PATCH 04/16] RISC-V: KVM: Implement VCPU create, init and destroy functions
From
Date
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

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.

Paolo

> I suggest adding a comment here, and again providing a ONE_REG interface
> to sstatus so that the ABI is final before RISC-V KVM is merged.
>
> What happens if the guest executes SRET? Is that EXC_SYSCALL in hedeleg?
>
> (BTW the name of SP2V and SP2P is horrible, I think HPV/HPP or HSPV/HSPP
> would have been clearer, but that's not your fault).

\
 
 \ /
  Last update: 2019-07-30 12:17    [W:0.128 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site