From 6c05af8ded265bfc28dcf0ec390fd2f56ee8ea72 Mon Sep 17 00:00:00 2001 From: Binbin Wu Date: Wed, 20 May 2020 04:54:28 +0000 Subject: [PATCH] hv: ptirq : fix a bug in ptirq_release_entry The mask valuei 0x3F was added to prevent out of range in array access. However, it should not be hardcoded. Since in ptirq_alloc_entry_id, the valid allocated id is no greater than CONFIG_MAX_PT_IRQ_ENTRIES, it will not cause out of range array access without mask. So this patch removes the mask. Also, use bitmap_clear_lock instead of bitmap_clear_nolock becuase there could be the chance that more than 1 core to access a same 64bit var. Tracked-On: #4828 Signed-off-by: Binbin Wu Acked-by: Eddie Dong --- hypervisor/common/ptdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hypervisor/common/ptdev.c b/hypervisor/common/ptdev.c index ebcdcbc58..c888258aa 100644 --- a/hypervisor/common/ptdev.c +++ b/hypervisor/common/ptdev.c @@ -149,8 +149,7 @@ void ptirq_release_entry(struct ptirq_remapping_info *entry) del_timer(&entry->intr_delay_timer); CPU_INT_ALL_RESTORE(rflags); - bitmap_clear_nolock((entry->ptdev_entry_id) & 0x3FU, - &ptirq_entry_bitmaps[((entry->ptdev_entry_id) & 0x3FU) >> 6U]); + bitmap_clear_lock((entry->ptdev_entry_id) & 0x3FU, &ptirq_entry_bitmaps[entry->ptdev_entry_id >> 6U]); (void)memset((void *)entry, 0U, sizeof(struct ptirq_remapping_info)); }