-
Notifications
You must be signed in to change notification settings - Fork 207
Add APOB messages to host_sp_comms #2006
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
base: master
Are you sure you want to change the base?
Conversation
task/host-sp-comms/src/main.rs
Outdated
hf.bonus_sector_erase(offset) | ||
.map_err(|err| APOBError::EraseFailed { offset, err })?; | ||
} else { | ||
// Read back the page and confirm that it's all empty |
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.
Could this fail if there's a blip in the IPCC path and the host resends an APOB
request? (I'm not sure what the expectations are for the offsets the host is providing.)
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 has changed a bunch since February; messages should now all be idempotent.
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.
Some mostly kind of annoying nitpicks.
3c34974
to
593980a
Compare
65a65da
to
ebcfe39
Compare
ded20cd
to
7846e44
Compare
task/host-sp-comms/src/main.rs
Outdated
fn apob_write( | ||
hf: &HostFlash, | ||
mut offset: u64, | ||
data: &[u8], | ||
) -> Result<(), ApobError> { |
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.
So we need something in the broader API to discover what the erase size granularity is or at least make sure that we're sending stuff that is page size aligned. This gets to what @jgallagher gets at below. But if the host sent things that wasn't page aligned then we'd erase the entire page because our API is not doing a read-modify-write.
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 has all changed now – we ensure that the to-be-written page is erased when the state machine starts, and writes are idempotent.
14165d3
to
b0acdc3
Compare
f7e8314
to
4a07f2b
Compare
ded1fa1
to
ad93477
Compare
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.
Will probably do another pass later
/// Either 0 or 1; directly translatable to [`ApobSlot`] | ||
pub slot_select: u32, | ||
|
||
/// CRC-32 over the rest of the data using the iSCSI polynomial |
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.
Any significance to the choice of polynomial? (curiosity more than anything)
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 copied what we used for HfRawPersistentData
😄
checksum: 0, // dummy value | ||
}; | ||
out.checksum = out.expected_checksum(); | ||
assert!(out.is_valid()); |
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.
assert
becomes panic, is that the behavior we want 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.
I think so; the only way this should panic is if someone has broken the code in a dramatic way (e.g. editing the implementation of is_valid
so that previously valid data is no longer valid).
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.
But this is also copied from HfRawPersistentData
, so I didn't think about it too much!
/// Either 0 or 1; directly translatable to [`ApobSlot`] | ||
pub slot_select: u32, |
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 are a couple of places where we have unreachable
because of using the u32
, maaaybe an enum would be cleaner and reduce a few checks? Or is the issue this needs to match exactly what the host is expecting?
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 isn't seen at all by the host, but we're reading / writing this object directly to disk, so we need zerocopy
-friendly types.
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.
FWIW, zerocopy::TryFromBytes
can be derived for enums (though I'm not sure how annoying that would be to actually use 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.
I think it would be usable, but the docs seem to imply that you shouldn't it when round-tripping through bytes (?!).
I've opened google/zerocopy#2722 to ask for clarification
fn fail(err: drv_hf_api::HfError) { | ||
let mut buffer = [0; hf::idl::INCOMING_SIZE]; | ||
let mut server = hf::idl::FailServer::new(err); | ||
let mut server = hf::FailServer(err); |
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.
Hmmm, do we lose the idl
generation of this?
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.
Yeah – I switched to finer-grained error types for a few methods, which means that the IDL generator can't make a FailServer
(which assumes a single error type).
drv/cosmo-hf/src/apob.rs
Outdated
pub(crate) fn write( | ||
&mut self, | ||
drv: &mut FlashDriver, | ||
offset: u64, |
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.
Do we need the u64
everywhere? It seems like everything gets converted/checked against u32
anyway
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.
The initial u64
is sent by the host, but I pushed the u32
conversion upstream into host_sp_comms
.
49afe3d
to
695c7d5
Compare
@mkeeter - here are the IPCC messages which are expected to be seen before the host is finished with APOB. Anything else incoming from the host should trigger the lockdown.
|
efc7039
to
8d35455
Compare
@citrus-it Great, thanks! I've pushed this list to Hubris and to RFD 593. |
8d35455
to
58e761d
Compare
58e761d
to
f883776
Compare
Implements the state machine described in RFD 593
See https://github.com/oxidecomputer/stlouis/issues/707, https://github.com/oxidecomputer/rfd/pull/855 , oxidecomputer/amd-host-image-builder#222