Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward debug console to host #190

Merged

Conversation

abrestic-rivos
Copy link
Collaborator

Forward debug console ECALLs (DBCN and legacy put_char) to a VM's host instead of handling console output directly within Salus. For guest TVMs, this means that that buffer to be printed must reside in memory shared with the host VM.

  • Patches 1&2 prepare for console forwarding by putting the DBCN buffer in shared memory.
  • Patches 3&4 forward the DBCN and put_char calls to the host, respectively.
  • Patch 5 forwards the return value from the host back to the guest for these ECALLs.

Looking for opinions on the forwarding of ECALL return values. Currently I'm just using A0/A1 from the shared memory area, which means the host will have to know which ECALLs for which it's expected to provide a return value. Other options I considered are: setting a flag (in shared memory?) that indicates to the host that it needs to provide a return value, or having a separate sbi_return struct in the shared memory area where the host puts the return value (with sentinel values to indicate whether or not the TSM is expecting to find something there).

Fixes #146

In preparation for forwarding debug console SBI calls to a VM's host, and
thus requiring that the buffer be in shared memory, have the user of
the SBI debug console provide the memory that will be used for buffering
console output in the call to set_as_console().

Signed-off-by: Andrew Bresticker <[email protected]>
In preparation for forwarding the debug console SBI calls from the guest
TVM to the host, have GuestVm put its debug console buffer in a shared
memory region that it converts at boot.

Signed-off-by: Andrew Bresticker <[email protected]>
Forward PutString calls to the VM's host. For the host VM, we pin the memory
backing the buffer that is to be printed while we write it to the console.
For Tellus, we confirm that the buffer is in shared memory before we go
print it.

Signed-off-by: Andrew Bresticker <[email protected]>
Like the debug console, this should get forwarded to the VM's host rather
than having Salus print directly to the console.

Signed-off-by: Andrew Bresticker <[email protected]>
For certain ECALLs (for now, just debug console) from guest VMs, we want to
forward the call to the host and have the host provide the return value.
Do this by taking the A0/A1 values from the guest GPRs in the shared memory
area when running the vCPU after it exits due to a forwarded ECALL, just
like we do for emulated MMIO loads.

Signed-off-by: Andrew Bresticker <[email protected]>
Copy link
Contributor

@atulkharerivos atulkharerivos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Collaborator

@dgreid dgreid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to drop legacy console soon so we can stop dealing with it.

For return values, I feel a0/a1 is fine, it's simple and VMMs will already have to support that pattern for non-TEE use cases.

LGTM, thanks.

@abrestic-rivos abrestic-rivos merged commit 40d9f0e into rivosinc:main Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forward guest VM SBI console output to host
3 participants