[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RISC-V] Switch to H-mode


  • To: Bobby Eshleman <bobbyeshleman@xxxxxxxxx>, Oleksii <oleksii.kurochko@xxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Mon, 23 Jan 2023 23:09:13 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MS2c150mQ60+qHYVrs8WlxwdtITVkNalm9pR6FWHaBQ=; b=hL4+yYPdWsOS1Rd8K7i8sUiBjwe94m5pvoetmE98JY8cx78jbB7uDjkZKaBi4Gye8AlMbifOBYES6vPl1yFyBO2n2Sc1htwrGhbF1qgy9Yge+yaI+NCgZEek1OYAqiCZ+pooGFHzpHnLUeLiDzqYix/19RFJk+XLUsVnfP64cIDHP1o9yz/KiakNqkOI5OrACTv2i6ZbCLt8psczpExP1A+e89zd+4oo2gU/FvkeV5XYy0Ws9VrGqh/n7KY2sBsSultDsdJ23wE5P606aAE6qiF9pCZ+yPlJ0yBUn9aJYpMUtcPOzS0tHQbyATDB93Jw6D/2uo6bpEPH0vyA24ZmHw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DHQ4BuL/CTm9DdfWN5XHInUfLsdatFeEs2Xp0mLpox6BVUIi370wTnis3eK4KR/AfkQgRm1zjxBM5XIQcY0BfyoEX5Q/Y/kxL6zvQ1oAKsI59wcZFzUGEYRrZHqzG0PA44z1t4O/7bUbu36bxEdeY+HqEtVWiZOsP434ojiOKM4XcFun/6idm9YeY2P11ycsGnA3TH1VEUGDIy/1ngZRHjx1AUUc1/VfVsx7JGisITS9r1hQEVrsKn0XUyq9F4sH7EqDXVKqYJUqEiPi43R+dS/6kJuWd0PAvRpINUP26zX/6tMar4P96N/7yuV77yIaxP6llvSCBgTA6ysCkJEfkw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Alistair Francis <alistair.francis@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>
  • Delivery-date: Mon, 23 Jan 2023 23:09:38 +0000
  • Ironport-data: A9a23:4eOPNKz/1b19hBNKuWB6t+e0xyrEfRIJ4+MujC+fZmUNrF6WrkUAz GQcWTuAaPyPZGGmL9B1bdvi90IEsZ+AmtIwGQtsqCAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTbaeYUidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+UwHUMja4mtC5QRnP6sT5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KT8X7 sMBbzQUVRqCqv2t7pW8SLQvne12eaEHPKtH0p1h5RfwKK98BLrlE+DN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvjWVlVIguFTuGIO9ltiibMNZhEuH4 EnB+Hz0GEoyP92D0zuVtHmrg4cjmAuqA9NJSuPlr5aGhnXC7Ug1Kz4QcGC2/9uZhG6YCutaC Rctr39GQa8asRbDosPGdxe/qnSVswUcX9dVGusS5wSEy66S6AGcbkADSjNCc90n8swrXzsh1 lyOt9zsDD1r9raSTBq1/7OVti+7ODJTI3ULYyQFViMa79Klq4Y25jrfQ9AmHKOrg9ndHTDr3 yvMvCU4n68Uj8MAy+O851+vqym3upHDQwox5wPWdmGo9AV0YMiifYPAwVfa5PBEMY2QZkOAo n8fms6VqusJCPmweDelRewMGPSj4aaDOTiF21p3RcB/pnKq5mKpep1W7HdmPkB1P80YeDjvJ kjOpQdW45wVN3yvBUNqX7+M5w0R5fCIPbzYujr8N7KivrAZmNe7wRxT
  • Ironport-hdrordr: A9a23:xsmkB6n+oAu5fwYl4kktZ/y5SWbpDfLo3DAbv31ZSRFFG/Fw9/ rCoB17726QtN91YhsdcL+7V5VoLUmzyXcX2/hyAV7BZmnbUQKTRekP0WKL+Vbd8kbFh41gPM lbEpSXCLfLfCJHZcSR2njELz73quP3jJxBho3lvghQpRkBUdAF0+/gYDzranGfQmN9dP0EPa vZ3OVrjRy6d08aa8yqb0N1JNQq97Xw5fTbiQdtPW9f1DWz
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZL3+1jFKdxw/fjUKAFDmhXbPnOg==
  • Thread-topic: [RISC-V] Switch to H-mode

On 19/01/2023 1:05 pm, Bobby Eshleman wrote:
> On Mon, Jan 23, 2023 at 06:56:19PM +0200, Oleksii wrote:
>> Hi Alistair and community,
>>
>> I am working on RISC-V support upstream for Xen based on your and Bobby
>> patches.
>>
>> Adding the RISC-V support I realized that Xen is ran in S-mode. Output
>> of OpenSBI:
>>     ...
>>     Domain0 Next Mode         : S-mode
>>     ...
>> So the first my question is shouldn't it be in H-mode?
>>
>> If I am right than it looks like we have to do a patch to OpenSBI to
>> add support of H-mode as it is not supported now:
>> [1]
>> https://github.com/riscv-software-src/opensbi/blob/master/lib/sbi/sbi_domain.c#L380
>> [2]
>> https://github.com/riscv-software-src/opensbi/blob/master/include/sbi/riscv_encoding.h#L110
>> Please correct me if I am wrong.
>>
>> The other option I see is to switch to H-mode in U-boot as I understand
>> the classical boot flow is:
>>     OpenSBI -> U-boot -> Xen -> Domain{0,...}
>> If it is at all possible since U-boot will be in S mode after OpenSBI.
>>
>> Thanks in advance.
>>
>> ~ Oleksii
>>
> Ah, what you are seeing there is that the openSBI's Next Mode excludes
> the virtualization mode (it treats HS and S synonymously) and it is only
> used for setting the mstatus MPP. The code also has next_virt for
> setting the MPV but I don't think that is exposed via the device tree
> yet. For Xen, you'd want next_mode = PRIV_S and next_virt = 0 (HS mode,
> not VS mode). The relevant setup prior to mret is here for interested
> readers:
> https://github.com/riscv-software-src/opensbi/blob/001106d19b21cd6443ae7f7f6d4d048d80e9ecac/lib/sbi/sbi_hart.c#L759
>
> As long as the next_mode and next_virt are set correctly, then Xen
> should be launching in HS mode. I do believe this should be default for
> the stock build too for Domain0, unless something has changed.

Ok, so everything ought to be doing the right thing, even if it doesn't
show up clearly in the logging.

At some point, Xen is going to need a `if ( !hs-mode ) panic();`,
because we can't operate dom0 properly if Xen is in plan S-mode.

I suggested that we try and make csr_read_safe() work, then try and read
`hstatus` to probe if the H extension is active.

Does this sound reasonable, or is there a better option?

~Andrew

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.