Browse Source

fix(gpt): fix RME GPT library bug

This patch fixes fill_l1_tbl() function bug
for RME_GPT_MAX_BLOCK build option set to 0
disabling filling L1 tables with Contiguous
descriptors.

Change-Id: I3eedd6c1bb55b7c207bb3630d1ab2fda8f72eb17
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
pull/2000/merge
AlexeiFedorov 5 months ago
parent
commit
6350aea2f1
  1. 18
      lib/gpt_rme/gpt_rme.c

18
lib/gpt_rme/gpt_rme.c

@ -700,8 +700,8 @@ static uintptr_t get_l1_end_pa(uintptr_t cur_pa, uintptr_t end_pa)
* Return * Return
* Address of next granule in range. * Address of next granule in range.
*/ */
static uintptr_t fill_l1_cont_desc(uint64_t *l1, uintptr_t first, __unused static uintptr_t fill_l1_cont_desc(uint64_t *l1, uintptr_t first,
size_t length, unsigned int gpi) size_t length, unsigned int gpi)
{ {
/* /*
* Look up table for contiguous blocks and descriptors. * Look up table for contiguous blocks and descriptors.
@ -826,8 +826,10 @@ static uintptr_t fill_l1_gran_desc(uint64_t *l1, uintptr_t first,
/* /*
* Helper function to fill out GPI entries in a single L1 table. * Helper function to fill out GPI entries in a single L1 table.
* This function fills out an entire L1 table with either Contiguous * This function fills out an entire L1 table with either Granules or Contiguous
* or Granules descriptors depending on region length and alignment. * (RME_GPT_MAX_BLOCK != 0) descriptors depending on region length and alignment.
* Note. If RME_GPT_MAX_BLOCK == 0, then the L1 tables are filled with regular
* Granules descriptors.
* *
* Parameters * Parameters
* l1 Pointer to L1 table to fill out * l1 Pointer to L1 table to fill out
@ -844,13 +846,14 @@ static void fill_l1_tbl(uint64_t *l1, uintptr_t first, uintptr_t last,
assert((last & (GPT_PGS_ACTUAL_SIZE(gpt_config.p) - 1UL)) == 0UL); assert((last & (GPT_PGS_ACTUAL_SIZE(gpt_config.p) - 1UL)) == 0UL);
assert(GPT_L0_IDX(first) == GPT_L0_IDX(last)); assert(GPT_L0_IDX(first) == GPT_L0_IDX(last));
#if (RME_GPT_MAX_BLOCK != 0)
while (first < last) { while (first < last) {
/* Region length */ /* Region length */
size_t length = last - first + GPT_PGS_ACTUAL_SIZE(gpt_config.p); size_t length = last - first + GPT_PGS_ACTUAL_SIZE(gpt_config.p);
if (length < SZ_2M) { if (length < SZ_2M) {
/* /*
* Fill with Granule descriptor in case of * Fill with Granule descriptors in case of
* region length < 2MB. * region length < 2MB.
*/ */
first = fill_l1_gran_desc(l1, first, last, gpi); first = fill_l1_gran_desc(l1, first, last, gpi);
@ -874,7 +877,10 @@ static void fill_l1_tbl(uint64_t *l1, uintptr_t first, uintptr_t last,
first = fill_l1_gran_desc(l1, first, new_last, gpi); first = fill_l1_gran_desc(l1, first, new_last, gpi);
} }
} }
#else
/* Fill with Granule descriptors */
first = fill_l1_gran_desc(l1, first, last, gpi);
#endif
assert(first == (last + GPT_PGS_ACTUAL_SIZE(gpt_config.p))); assert(first == (last + GPT_PGS_ACTUAL_SIZE(gpt_config.p)));
} }

Loading…
Cancel
Save