Question about guest external interrupt


Oscar Jupp
 


To whom it may concern,
I have a question about guest external interrupt.
The privileged ISA said: "GEILEN may be zero". If GEILEN is zero, is the implementation unable to receive guest external interrupts at all? Or can it be injected by software means?
Any help would be greatly appreciated!
Regards
Oscar Jupp


Anup Patel
 

On Thu, Nov 17, 2022 at 9:07 AM Oscar Jupp <jupposcar@...> wrote:


To whom it may concern,
I have a question about guest external interrupt.
The privileged ISA said: "GEILEN may be zero". If GEILEN is zero, is the implementation unable to receive guest external interrupts at all? Or can it be injected by software means?
If GEILEN is zero then there are no guest external interrupts but
software (i.e. hypervisor) can still inject external interrupts using
hvip CSR. In other words, software-injected external interrupts are
always available to a hypervisor using H-extension.

Regards,
Anup

Any help would be greatly appreciated! Thank you
Regards
Oscar Jupp


Oscar Jupp
 

Dear Anup Patel,
Thank you very much for your reply.
 I would like to continue to ask: If GEILEN is 0, CSR hgeip and hgeie will always be all zero. Then, hip.SGEIP is always 0. You said: “software (i.e. hypervisor) can still inject external interrupts using hvip CSR. “ But hvip CSR can only make hip.VSSIP, hip.VSTIP and hip.VSEIP raised. It can not make hip.SGEIP be “1”. How does the implement recognize that this is a guest external interrupt.

Regards,
Oscar Jupp


---- Replied Message ----
From Anup Patel<apatel@...>
Date 11/17/2022 11:56
To Oscar Jupp<jupposcar@...>
Cc tech-privileged@...<tech-privileged@...>
Subject Re: [RISC-V] [tech-privileged] Question about guest external interrupt
On Thu, Nov 17, 2022 at 9:07 AM Oscar Jupp <jupposcar@...> wrote:


To whom it may concern,
I have a question about guest external interrupt.
The privileged ISA said: "GEILEN may be zero". If GEILEN is zero, is the implementation unable to receive guest external interrupts at all? Or can it be injected by software means?

If GEILEN is zero then there are no guest external interrupts but
software (i.e. hypervisor) can still inject external interrupts using
hvip CSR. In other words, software-injected external interrupts are
always available to a hypervisor using H-extension.

Regards,
Anup

Any help would be greatly appreciated! Thank you
Regards
Oscar Jupp


Scott Johnson
 

External interrupts are passed through to the guest by setting `hip.VSEIP`, which the guest OS sees as `sip.SEIP`.

The hypervisor software decides which interrupts should be passed through to which guest OS.

If the hardware has GEILEN>0 then the hypervisor software can configure `hstatus.VGEIN` and `hgeie` such that `hip.VSEIP` can be set by the external interrupt directly.

If the hardware has GEILEN=0 then the external interrupt will first go to the hypervisor software, which can pass through the interrupt to the guest by setting `hvip.VSEIP`.

Either way, the guest OS sees the same thing.


Oscar Jupp
 

Dear Scott Johnson,
Thank you very much!
You said: “If the hardware has GEILEN=0 then the external interrupt will first go to the hypervisor software, which can pass through the interrupt to the guest by setting `hvip.VSEIP`.”
Do you mean that the hypervisor can distinguish between the external interrupt to the physical machine and external interrupt to the guest?
How does the hypervisor know which interrupt is a external interrupt to the physical machine? Or is it a external interrupt to the guest?

Regards,
Oscar Jupp


---- Replied Message ----
From Scott Johnson<scott.johnson@...>
Date 11/17/2022 22:56
To <tech-privileged@...>
Subject Re: [RISC-V] [tech-privileged] Question about guest external interrupt
External interrupts are passed through to the guest by setting `hip.VSEIP`, which the guest OS sees as `sip.SEIP`.

The hypervisor software decides which interrupts should be passed through to which guest OS.

If the hardware has GEILEN>0 then the hypervisor software can configure `hstatus.VGEIN` and `hgeie` such that `hip.VSEIP` can be set by the external interrupt directly.

If the hardware has GEILEN=0 then the external interrupt will first go to the hypervisor software, which can pass through the interrupt to the guest by setting `hvip.VSEIP`.

Either way, the guest OS sees the same thing.


Scott Johnson
 

They are all external interrupts to the physical machine. The hypervisor software will decide which, if any, of these external interrupts should be passed through to which guest OS, and direct the appropriate ones through hardware (if GEILEN>0) or software (if GEILEN=0).

This is explained in the privileged spec under hgeip:

If a RISC-V platform supports placing a physical device under the direct control of a guest OS with

minimal hypervisor intervention (known as pass-through or direct assignment between a virtual machine

and the physical device), then, in such circumstance, interrupts from the device are intended

for a specific virtual machine.



I would imagine the hypervisor software will have some kind of UI or API for the user to associate a particular hardware device with a particular guest OS. This enables higher performance than the alternative of virtualizing every device so they can be shared across all guests.

GEILEN>0 enables this pass-through to be higher performance because it doesn’t require the intervention of the hypervisor software on every single interrupt.



On Nov 17, 2022, at 9:02 PM, jupposcar <jupposcar@...> wrote:

Dear Scott Johnson,
Thank you very much!
You said: “If the hardware has GEILEN=0 then the external interrupt will first go to the hypervisor software, which can pass through the interrupt to the guest by setting `hvip.VSEIP`.”
Do you mean that the hypervisor can distinguish between the external interrupt to the physical machine and external interrupt to the guest?
How does the hypervisor know which interrupt is a external interrupt to the physical machine? Or is it a external interrupt to the guest?

Regards,
Oscar Jupp