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

cpu: implement IPI support #579

Merged
merged 5 commits into from
Jan 13, 2025
Merged

cpu: implement IPI support #579

merged 5 commits into from
Jan 13, 2025

Conversation

msft-jlange
Copy link
Collaborator

This change includes logic to support sending inter-processor interrupts (IPIs) to other processors. An IPI can be sent as a multicast message, or as a unicast message to a specific processor as a mutable message which receives a response. All IPI delivery is synchronous, meaning that the sender will block until the IPI is delivered and the receiver has processed it.

@msft-jlange msft-jlange force-pushed the ipi branch 2 times, most recently from dcc98e1 to 101a911 Compare December 18, 2024 17:01
Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, Jon. I left a view review comments.

kernel/src/cpu/cpuset.rs Outdated Show resolved Hide resolved
kernel/src/cpu/ipi.rs Outdated Show resolved Hide resolved
kernel/src/cpu/ipi.rs Show resolved Hide resolved
kernel/src/cpu/ipi.rs Outdated Show resolved Hide resolved
kernel/src/utils/scoped.rs Outdated Show resolved Hide resolved
@joergroedel joergroedel added the in-review PR is under active review and not yet approved label Dec 20, 2024
@msft-jlange msft-jlange force-pushed the ipi branch 3 times, most recently from bea6820 to 5d94146 Compare December 21, 2024 22:22
@msft-jlange
Copy link
Collaborator Author

I've added the Sync trait bound to multicast messages since those messages can be referenced simultaneously by multiple threads. Sync is not needed for unicast messages because they do not have multi-thread visibility.

Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

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

Overall this looks good to me. There are two things I mentioned in separate comments which need attention.

kernel/src/cpu/cpuset.rs Outdated Show resolved Hide resolved
kernel/src/cpu/ipi.rs Show resolved Hide resolved
KVM does not support tracking interrupt state separately for each VMPL.
The use of interrupts by the SVSM should be suppressed when running with
SNP any time the SVSM is running under KVM/QEMU, not just when
restricted injection is enabled.

Signed-off-by: Jon Lange <[email protected]>
`CpuSet` is an object that can represent a set of CPUs.  Two versions
are defined, both atomic and non-atomic.  The atomic version permits
multiple threads to simultaneously add, remove, or iterate elements of
the set.

Signed-off-by: Jon Lange <[email protected]>
`ScopedRef` and `ScopedMut` are designed to solve the problem of
managing lifetimes of references created from pointers.  Normally, when
a reference is created from a pointer (such as with `ptr::as_ref()`), it
is associated with the static lifetime, and as a result, the compiler is
unable to determine whether the reference will live long enough for its
intended use.  While functions like `ptr::as_ref()` can associate the
reference with a lifetime, the compiler cannot usefully use this
information to enfoce lifetime checks on pointers generated in this way
because although every reference can be bound to a lifetime, a reference
does not by itself own a lifetime, and without an owning lifetime, the
compiler has no way to know when the lifetime to which the reference is
bound goes out of scope.  The `ScopedRef` and `ScopedMut` objects solve
this by creating a new object every time a pointer is converted to a
reference, so there is an actual object with an associated lifetime that
the compiler can use to ensure that the reference remains valid.

Signed-off-by: Jon Lange <[email protected]>
The address of a `PerCpuShared` as observed by the local CPU is
different than the address of the same `PerCpuShared` observed by other
CPUs in the global address space.  There are cases where a local CPU
needs to know the address that will be used by other CPUs.

Signed-off-by: Jon Lange <[email protected]>
This change provides routines that enable one processor to send a
message to one or other processors to perform work.

Signed-off-by: Jon Lange <[email protected]>
@joergroedel joergroedel merged commit b8e9975 into coconut-svsm:main Jan 13, 2025
4 checks passed
@msft-jlange msft-jlange deleted the ipi branch January 13, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-review PR is under active review and not yet approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants