Skip to content

Commit 2d707b4

Browse files
yong-xuanavpatel
authored andcommitted
RISC-V: KVM: No need to use mask when hart-index-bit is 0
When the maximum hart number within groups is 1, hart-index-bit is set to 0. Consequently, there is no need to restore the hart ID from IMSIC addresses and hart-index-bit settings. Currently, QEMU and kvmtool do not pass correct hart-index-bit values when the maximum hart number is a power of 2, thereby avoiding this issue. Corresponding patches for QEMU and kvmtool will also be dispatched. Fixes: 89d0130 ("RISC-V: KVM: Implement device interface for AIA irqchip") Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20240415064905.25184-1-yongxuan.wang@sifive.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent 1613e60 commit 2d707b4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/riscv/kvm/aia_device.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ static gpa_t aia_imsic_ppn(struct kvm_aia *aia, gpa_t addr)
237237

238238
static u32 aia_imsic_hart_index(struct kvm_aia *aia, gpa_t addr)
239239
{
240-
u32 hart, group = 0;
240+
u32 hart = 0, group = 0;
241241

242-
hart = (addr >> (aia->nr_guest_bits + IMSIC_MMIO_PAGE_SHIFT)) &
243-
GENMASK_ULL(aia->nr_hart_bits - 1, 0);
242+
if (aia->nr_hart_bits)
243+
hart = (addr >> (aia->nr_guest_bits + IMSIC_MMIO_PAGE_SHIFT)) &
244+
GENMASK_ULL(aia->nr_hart_bits - 1, 0);
244245
if (aia->nr_group_bits)
245246
group = (addr >> aia->nr_group_shift) &
246247
GENMASK_ULL(aia->nr_group_bits - 1, 0);

0 commit comments

Comments
 (0)