Skip to content

Make hiffy callable over the network#2466

Merged
mkeeter merged 4 commits intomasterfrom
mkeeter/hiffy-net
Apr 24, 2026
Merged

Make hiffy callable over the network#2466
mkeeter merged 4 commits intomasterfrom
mkeeter/hiffy-net

Conversation

@mkeeter
Copy link
Copy Markdown
Collaborator

@mkeeter mkeeter commented Apr 8, 2026

For too long, a network-attached Humility has only been able to run a subset of hiffy programs (ones that exclusively use the Send operations, using the udprpc hack). This PR adds a net feature to the hiffy task, restoring it to full usefulness when network-attached.

hiffy accepts three messages:

  • Write program text
  • Write data
  • Kick (begin execution)

For simplicity, these messages only write to RAM. Even the HiffyKick message doesn't actually start execution itself; it just sets the HIFFY_KICK variable, which is checked the main loop. This mimics the behavior of the debugger.

Interestingly, we don't need any new infrastructure to read the results; we can use the existing RAM-reading infrastructure.

Unfortunately, Github is butchering the diff here. The existing code (look for kick, run program) is unchanged but for indentation, because we have two notifications (timer and net activity). If the new net notification fires, then we handle the packet in a new net::State object.

I'm opening this as a draft while I polish up the Humility side, but it's ready for review now.

@mkeeter mkeeter force-pushed the mkeeter/hiffy-net branch 7 times, most recently from d116c1e to 54b42af Compare April 13, 2026 15:27
@mkeeter mkeeter marked this pull request as ready for review April 14, 2026 14:32
@mkeeter
Copy link
Copy Markdown
Collaborator Author

mkeeter commented Apr 14, 2026

Marking this a ready-for-review now that oxidecomputer/humility#616 is out

@mkeeter mkeeter force-pushed the mkeeter/hiffy-net branch from 54b42af to b95a834 Compare April 14, 2026 15:22
Copy link
Copy Markdown
Contributor

@lzrd lzrd left a comment

Choose a reason for hiding this comment

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

I would fix the repeated literal constants.
It would be nice to see all of the loop timing and retry constants be together.

Comment thread task/hiffy/src/main.rs
sleeps = 0;
// Exponentially backoff our sleep value, but no more than 250ms
if sleeps == 10 {
sleep_ms = core::cmp::min(sleep_ms * 10, 250);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same literal constant repeated. Make it symbolic.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can you suggest names for these constants? The first 10 is "number of iterations to run between updates to sleep_ms", the second 10 is "scale factor between updates"; neither of them have a good pithy name.

(This is also unchanged from the previous code, just indented)

Comment thread task/hiffy/src/main.rs Outdated
rstack,
&mut *HIFFY_SCRATCH.borrow_mut(),
check,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We're in an intentional insecure mode. But, do we at least get an integrity check on the network transport? There isn't one at this layer. This is debug/YOLO mode, but a light check to scope a data corruption error would be good.
Maybe just a comment on data integrity for now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We use IPv6 UDP, which has a 16-bit checksum. This is true for all Hubris network activity, so calling out Hiffy as uniquely bad doesn't make sense to me.

@mkeeter mkeeter force-pushed the mkeeter/hiffy-net branch 2 times, most recently from 1dc7422 to 9dfe770 Compare April 16, 2026 19:39
Comment thread task/hiffy/src/main.rs
Comment on lines +183 to +187
if notif.check_notification_mask(notifications::SOCKET_MASK) {
net_state.check_net();
}

if notif.has_timer_fired(notifications::TIMER_MASK) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It feels odd to potentially check the net task here and then also have to check the timer. It's probably fine and I think I'm having a strong reaction to this not being an idol server (hiffy probably pre-dates that?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can you say more about why it feels odd? We're waiting on the combined net + timer notification bits, so it seems reasonable to check which one(s) fired and proceed accordingly.

I did consider making this an Idol server, but decided against it:

  • hiffy doesn't expose any public IPCs
  • We'd end up doing the same notification checks in the impl NotificationHandler, with more indirection / overhead from the Idol runtime

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was initially concerned about TOCTOU with the net and timer aligning in weird ways but I don't think that's actually a concern on re-review

Comment thread task/hiffy/src/main.rs Outdated
Comment on lines +208 to +213
// TODO without a safety comment explaining why these are safe, it is
// not clear if this is sound, do _not_ "fix" this by slapping on an
// addr_of_mut! without further analysis!
let text = unsafe { &HIFFY_TEXT };
let data = unsafe { &HIFFY_DATA };
let rstack = unsafe { &mut HIFFY_RSTACK[0..] };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we're less unsound but do we need further discussion either her or in another comment about interactions between hiffy over probe and hiffy over the network? I can handwave about soundness okay from one external input source (probe) but two (net and probe) makes things more complicated. Is using both net hiffy and probe hiffy in the category of "don't do that"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

How about we bring in #2475 first, then I update this PR to use those new primitives (e.g. lifetime-bounded slices)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes I think that would make things easier to reason about

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done and rebased!

@mkeeter mkeeter force-pushed the mkeeter/hiffy-net branch from 9dfe770 to 2a76ffe Compare April 21, 2026 20:35
@mkeeter mkeeter force-pushed the mkeeter/hiffy-net branch from 2a76ffe to e262ed1 Compare April 23, 2026 14:28
@mkeeter mkeeter force-pushed the mkeeter/hiffy-net branch from e262ed1 to bcb5058 Compare April 24, 2026 14:07
@mkeeter mkeeter merged commit 2eaff9a into master Apr 24, 2026
230 of 346 checks passed
@mkeeter mkeeter deleted the mkeeter/hiffy-net branch April 24, 2026 14: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.

3 participants