Skip to content

Commit

Permalink
create a size variable for the sbi_hart_ext
Browse files Browse the repository at this point in the history
On some platforms, e.g. coreboot, opensbi fails as the loop in
fdt_parse_isa_one_hart is for SBI_HART_EXT_MAX (32) items,
and the array is only 15 at present.

Create a variable, sbi_hart_ext_size, which can be used
in for loops and other conditionals.

Signed-off-by: Ronald G Minnich <[email protected]>
  • Loading branch information
rminnich committed Apr 5, 2024
1 parent 29ecda9 commit 357273a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/sbi/sbi_hart.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct sbi_hart_ext_data {
};

extern const struct sbi_hart_ext_data sbi_hart_ext[];
extern const int sbi_hart_ext_size;

/*
* Smepmp enforces access boundaries between M-mode and
Expand Down
2 changes: 2 additions & 0 deletions lib/sbi/sbi_hart.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
__SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG),
};

const int sbi_hart_ext_size = sizeof(sbi_hart_ext) / sizeof(sbi_hart_ext[0]);

/**
* Get the hart extensions in string format
*
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/fdt/fdt_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static int fdt_parse_isa_one_hart(const char *isa, unsigned long *extensions)
continue; \
}

for (j = 0; j < SBI_HART_EXT_MAX; j++) {
for (j = 0; j < sbi_hart_ext_size; j++) {
set_multi_letter_ext(sbi_hart_ext[j].name,
sbi_hart_ext[j].id);
}
Expand Down

0 comments on commit 357273a

Please sign in to comment.