-
Notifications
You must be signed in to change notification settings - Fork 40
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
The control plane should use libipcc #4536
Conversation
To test this I ran some tests on a bench gimlet. First off let's make sure installinator can lookup the
Using a butler to adjust the size of the
Change
Crashing the SP during key lookup:
Remove the key completely:
Restoring a valid configuration again:
|
@@ -13,7 +13,7 @@ rustdocflags = "--document-private-items" | |||
# things critical to correctness probably don't belong here. | |||
[target.x86_64-unknown-illumos] | |||
rustflags = [ | |||
"-C", "link-arg=-Wl,-znocompstrtab" | |||
"-C", "link-arg=-Wl,-znocompstrtab,-R/usr/platform/oxide/lib/amd64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a workaround I was using to get around a missing run path. The solution is likely somewhere in the rpath
crate - I am diverting my attention to fixing this now, but if someone has pointers on how this should be done, that would be greatly appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spoke to dap about this and I plan to push a commit to clean up this mess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: opting to go with passing the oxide platform directory here after some discussion in chat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited to see this land! Some comments and questions
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#[cfg(target_os = "illumos")] | ||
static OXIDE_PLATFORM: &str = "/usr/platform/oxide/lib/amd64/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth a comment explaining what this path is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 77bd065.
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, | ||
} | ||
|
||
pub(crate) const LIBIPCC_ERR_OK: libipcc_err_t = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing doc comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 77bd065.
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, | ||
} | ||
|
||
pub(crate) const LIBIPCC_ERR_OK: libipcc_err_t = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would prefer if there are newlines between the constants, since it helps with readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 77bd065.
ipcc/src/handle.rs
Outdated
LIBIPCC_ERR_NO_MEM => IpccError::NoMem(inner), | ||
LIBIPCC_ERR_INVALID_PARAM => IpccError::InvalidParam(inner), | ||
LIBIPCC_ERR_INTERNAL => IpccError::Internal(inner), | ||
LIBIPCC_ERR_KEY_UNKNOWN => IpccError::Internal(inner), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be IpccError::KeyUnknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch -- dang it copy and paste!
Fixed in 77bd065.
ipcc/src/lib.rs
Outdated
//! An interface to libipcc (inter-processor communications channel) which | ||
//! currently supports looking up values stored in the SP by key. These | ||
//! values are passed from the control plane to the SP (through MGS) or | ||
//! are maniuplated through the `ipcc` command found on Helios. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "manipulated"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary after accepting Andy's change.
// Copyright 2023 Oxide Computer Company | ||
|
||
use crate::IpccError; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a comment in here that these stubs are for not-illumos platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 77bd065.
} | ||
|
||
/// Interface to the inter-processor communications channel. | ||
/// For more information see rfd 316. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there docs for the illumos library as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no documentation for the library other than the header file. I thought about linking the ipcc driver man page but the point of libipcc is that users don't call the kernel driver interface directly anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be man pages for libipcc in the next week or so.
|
||
impl Drop for IpccHandle { | ||
fn drop(&mut self) { | ||
unsafe { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each unsafe block, it would be to have a comment explaining why the code is safe across FFI boundaries. An example of what I mean:
omicron/sled-agent/src/swap_device.rs
Lines 434 to 448 in 30d4191
// Safety: CStr::from_ptr is documented as safe if: | |
// 1. The pointer contains a valid null terminator at the end of | |
// the string | |
// 2. The pointer is valid for reads of bytes up to and including | |
// the null terminator | |
// 3. The memory referenced by the return CStr is not mutated for | |
// the duration of lifetime 'a | |
// | |
// (1) is true because we initialize the buffers for ste_path as all | |
// 0s, and their length is long enough to include the null | |
// terminator for all paths on the system. | |
// (2) should be guaranteed by the syscall itself, and we can know | |
// how many entries are valid via its return value. | |
// (3) We aren't currently mutating the memory referenced by the | |
// CStr, though there's nothing here enforcing that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added safety comments to unsafe blocks that were not calls into libipcc itself since calling any C function has to be marked unsafe. So all the usage of CString and CStr list why they are safe. Let me know if you would like more safety comments elsewhere.
Co-authored-by: Andy Fiddaman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Excited to land this (modulo buildomat worker OS versions getting updated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this, I'm pleased to see the last direct ipcc ioctl user quashed.
Modulo the tests passing, approved.
Just putting this here in case others search for this error message: this PR appears to move forward the minimum Helios that the build machine must be running to 2.0.22221 from October 12th, 2023 (thanks @citrus-it). If you're on a machine that's too old, you'll see a message like this:
You should generally be able to update Helios machines with |
With oxidecomputer/illumos-gate@779fb5b now integrated we should use libipcc in omicron rather than make direct calls via
ioctl
. The library will take care of hiding the implementation details from upstream consumers -- this becomes important in the future when communication with the service processor from the host OS physically changes with newer board design.Currently the only consumer in this repo is installinator but the control plane is about to start communicating with the RoT via IPCC as well.
This PR introduces new bindings around
libipcc
and removes the oldioctl
interfaces.