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

Clarify hart_mask_base requirements #197

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

jones-drew
Copy link
Contributor

hart_mask_base doesn't need to be valid unless bit0 of hart_mask is set, since the base isn't used independently. Clarify this to ensure implementations don't return SBI_ERR_INVALID_PARAM for invalid hart_mask_base when hart_mask isn't selecting it.

@avpatel
Copy link
Contributor

avpatel commented Feb 16, 2025

Overall looks good to me but there is spec build failure.

Add separate first commit in this PR to fix this build issue. Here's how we fixed it for BRS spec (commit)

hart_mask_base doesn't need to be valid unless bit0 of hart_mask is
set, since the base isn't used independently. Clarify this to ensure
implementations don't return SBI_ERR_INVALID_PARAM for invalid
hart_mask_base when hart_mask isn't selecting it.

Signed-off-by: Andrew Jones <[email protected]>
@atishp04 atishp04 merged commit 2b09fad into riscv-non-isa:master Feb 18, 2025
2 checks passed
@SiFiveHolland
Copy link
Contributor

hart_mask_base doesn't need to be valid unless bit0 of hart_mask is set, since the base isn't used independently.

Where does this requirement come from? Why is bit 0 special? If I want to select hart 2, why can't I set hart_mask_base to 0 and set bit 2?

This isn't how existing software works, for example: https://github.com/riscv-software-src/opensbi/blob/fe11dee7eaeef71c4e03f8244f1b3d16b8cac460/lib/sbi/sbi_ipi.c#L124.

@SiFiveHolland
Copy link
Contributor

SiFiveHolland commented Feb 18, 2025

@radimkrcmar
Copy link
Contributor

If I want to select hart 2, why can't I set hart_mask_base to 0 and set bit 2?

It's the other way around. The spec should now say that you can, while you couldn't before. SBI now returns an error only if hart_mask bit 0 is set when the hart with id of hart_mask_base is invalid.

@SiFiveHolland
Copy link
Contributor

It's the other way around. The spec should now say that you can, while you couldn't before. SBI now returns an error only if hart_mask bit 0 is set when the hart with id of hart_mask_base is invalid.

Ah, I see now how you're interpreting it. I never thought of hart_mask_base as being itself a hartid, only as helping to define the mask. So I read the change as "hart_mask_base does not need to be an enabled or supervisor available
hartid [because the entire hart mask is ignored] unless the zeroth bit of hart_mask is set."

With a fresh look, the change looks good to me.

@radimkrcmar
Copy link
Contributor

Maybe we could move the note to the changelog (or just remove it). You're right that no-one should think that the note is needed... it only made sense to people who knew how the spec was before.

@jones-drew
Copy link
Contributor Author

Maybe we could move the note to the changelog (or just remove it). You're right that no-one should think that the note is needed... it only made sense to people who knew how the spec was before.

But above the note we have:

  • unsigned long hart_mask is a scalar bit-vector containing hartids
  • unsigned long hart_mask_base is the starting hartid from which the
    bit-vector must be computed.

We could try to reword hart_mask_base's definition, but I feel like it would get convoluted, and the current "starting hartid" may imply a valid hartid to some readers, simply because references to hartids aren't generally to potentiality invalid hartids.

@atishp04
Copy link
Collaborator

I also had the same interpretation as @SiFiveHolland at first read. I think the commit text is bit confusing. The note in the actual commit makes more sense.

hart_mask_base does not need to be an enabled or supervisor available hartid unless the zeroth bit of hart_mask is set.

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.

5 participants