riscv / riscv-smmtt

This specification will define the RISC-V privilege ISA extensions required to support Supervisor Domain isolation for multi-tenant security use cases e.g. confidential-computing, trusted platform services, fault isolation and so on.
https://jira.riscv.org/browse/RVG-65
Creative Commons Attribution 4.0 International
33 stars 15 forks source link

v0.1 Comments/Questions: What's the purpose for delegate LDSEI defined in Chapter 6 Smdia #70

Open ram2532 opened 2 weeks ago

ram2532 commented 2 weeks ago

Chapter 6 "Smdia: Supervisor Domain Interrupt Assigment" ends with this comment regarding the purpose for delegate LDSEI:

The delegation supports optimizing the exit sequence from such supervisor domain by enabling such supervisor domains to voluntarily yield execution in response to pending interrupts for the other supervisor domains.

I don't understand what is being optimized here. A transition to M-mode still needs to happen so that M-mode can switch the context to the interrupted SDID so that the interrupt can be handled. I don't understand the purpose for this delegation.

I also think this chapter would benefit from a S/W view of how S/W would use the Smsdia functionality to manage external supervisor interrupts across multiple SDIDs. I infer from the description of the CSRs, that M-mode would need to clear the msdeie bit corresponding to the SDID of the Supervisor context to which it will MRET. I think a description of how M-mode handles these transitions would be helpful.

gagachang commented 1 week ago

Hi @ram2532 ,

I don't understand what is being optimized here. A transition to M-mode still needs to happen so that M-mode can switch the context to the interrupted SDID so that the interrupt can be handled. I don't understand the purpose for this delegation.

Consider that SD(1) is running, and suddenly an SD(2)'s interrupt is asserted. The general program flow is:

  1. M-mode receives LSDEI which is from SD(2)'s interrupt controller
  2. M-mode should notify SD(1) and MRET to SD(1), to let SD(1) suspend itself
  3. SD(1) suspends itself, then executes ecall to go back to M-mode
  4. M-mode switches context to SD(2) to let SD(2) handle this interrupt

The delegation of LSDEI can eliminate the step 1 and step 2. Because the delegation makes SD(1) receive LSDEI directly. The M-mode's notification is unnecessary.