mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-29 19:01:47 +01:00
lib: sbi_mpxy: Fix shared memory size rounding
The sbi_mpxy_register_channel() currently performs ceiling division by
PAGE_SIZE but stores the resulting page count in mpxy_shmem_size. All
consumers interpret mpxy_shmem_size as a byte count, so channels requiring
more than one page get an undersized shared memory value.
Address the above issue by using ROUNDUP() to keep the rounded value in
bytes.
Fixes: ec09918426 ("lib: sbi: Update MPXY framework and SBI extension as per latest spec")
Signed-off-by: Shibo Zhu <3499129952@qq.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/tencent_14AA3BA0083001905C262A5CD64E442FC205@qq.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
+2
-2
@@ -257,8 +257,8 @@ int sbi_mpxy_register_channel(struct sbi_mpxy_channel *channel)
|
||||
|
||||
/* Update shared memory size if required */
|
||||
if (mpxy_shmem_size < channel->attrs.msg_data_maxlen) {
|
||||
mpxy_shmem_size = channel->attrs.msg_data_maxlen;
|
||||
mpxy_shmem_size = (mpxy_shmem_size + (PAGE_SIZE - 1)) / PAGE_SIZE;
|
||||
mpxy_shmem_size = ROUNDUP(channel->attrs.msg_data_maxlen,
|
||||
PAGE_SIZE);
|
||||
}
|
||||
|
||||
sbi_list_add_tail(&channel->head, &mpxy_channel_list);
|
||||
|
||||
Reference in New Issue
Block a user