Skip to content

Commit

Permalink
fix(riscv/sbi): rfence hart mask adjustment and check
Browse files Browse the repository at this point in the history
Right now, the sbi rfence implementation only supports 64 harts, so the
hart mask has to be rectified for always base 0 and return error if an
with hart id >= 64 is being targeted. Both this check and the hart
adjusment were being incorrectly performed.

Signed-off-by: Jose Martins <[email protected]>
  • Loading branch information
josecm authored and danielRep committed Oct 16, 2023
1 parent 8459a8e commit b1488a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/arch/riscv/sbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ struct sbiret sbi_rfence_handler(unsigned long fid)

const size_t hart_mask_width = sizeof(hart_mask) * 8;
if ((hart_mask_base != 0) && ((hart_mask_base >= hart_mask_width) ||
((hart_mask >> hart_mask_base) != 0)))
((hart_mask << hart_mask_base) == 0)))
{
WARNING("sbi invalid hart_mask");
return (struct sbiret){SBI_ERR_INVALID_PARAM};
}

hart_mask = hart_mask >> hart_mask_base;
hart_mask = hart_mask << hart_mask_base;

unsigned long phart_mask = vm_translate_to_pcpu_mask(
cpu()->vcpu->vm, hart_mask, sizeof(hart_mask) * 8);
Expand Down

0 comments on commit b1488a3

Please sign in to comment.