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

Additional changes for Sscdeleg support... #1

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

atulkharerivos
Copy link
Owner

@atulkharerivos atulkharerivos commented Dec 29, 2022

Per the offline discussion, the initial PR for the Supervisor Delegation Counter proposal (Sscdeleg) was split into two separate PRs.

  1. The first three commits in this request are the same as the aforementioned PR.
  2. The fourth commit adds support to detect the Sscdeleg extension.
  3. The fifth commit adds Sscdeleg related CSR and related definitions
  4. The sixth commit adds support to implement support for PMU counters in HS-mode (Sscdeleg platforms), or delegation to M-mode (legacy platforms)

Note that the functionality requires additional QEMU+OpenSBI changes (see below).

@atulkharerivos atulkharerivos force-pushed the topic/sscdel_additional_changes branch from 0439d98 to 950cbc6 Compare December 29, 2022 17:31
abrestic-rivos and others added 11 commits January 3, 2023 09:00
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]>
This adds support for the previously missing PMU Raw event type.
This doesn't contain any functional change, and centralizes the logic
for PMU counter configuration, start, and stop into vm_pmu.rs.
This adds a bug fix to translate the uinh/sinh passed by the TVM into
:vuinh/vsinh before passing them to M-mode.
crosvm has dropped the assertions crate in favor of the more commonly
used static_assertions crate. This change does the same for salus.
This breaks the only local dep in sbi which will allow that crate to be
pulled out and re-used more easily.

Signed-off-by: Dylan Reid <[email protected]>
See: rust-lang/rust#105572
Trait implementations adding more restrictive constrains to a trait
definition will soon be an error.

Luckily, it doesn't seem that this 'static lifetime bound is needed by
`PageBox` so remove it to make newer versions of rust happy.

Signed-off-by: Dylan Reid <[email protected]>
I meant to do monthly updates, but this went to almost two months, so
it's time.

Signed-off-by: Dylan Reid <[email protected]>
Copy link

@atishp04 atishp04 left a comment

Choose a reason for hiding this comment

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

LGTM.

@atulkharerivos atulkharerivos force-pushed the topic/sscdel_additional_changes branch 2 times, most recently from 50f293b to 70d7cb2 Compare January 4, 2023 05:04
A recent refactoring of the PMU counter logic had introduced a latent
bug that was exposed by a code change that introduced an additional
context switch between counter configuration and start. The gist is
that on the outbound path, the code change was causing the internal
bookkeeping to revert it back to the non-configured state, meaning
that the subsequent call to start the counter would fail.

This fixes the issue by introducing helper functions that help
distinguish between the internal code paths required required for
context switch operations, and SBI calls initiated by the VM.
This adds code to detect support for the Supervisor Counter
Delegation proposal.
This adds CSR definitions and register bitfields for the CSRs defined
the Supervisor Counter Delegation proposal.
On platforms with support for Supervisor Counter Delegation, PMU
functionality can be handled entirely in the HS-mode, thereby obviating
the need SBI calls to M-mode.

The changes seamlessly support both Sscdeleg and legacy platforms.
@atulkharerivos atulkharerivos force-pushed the topic/sscdel_additional_changes branch from 70d7cb2 to 53bb81c Compare January 4, 2023 21:39
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.

4 participants