From 5356fdc520c8b126823ac0079e9d4cd4329cfe40 Mon Sep 17 00:00:00 2001 From: Jian Jun Chen Date: Fri, 29 Jan 2021 11:48:46 +0800 Subject: [PATCH] hv: ivshmem: BAR0 size should be 256 Bytes ivshmem spec says that the size of BAR0 is 256 bytes. Windows ivshmem driver will check the size of BAR0. It will refuse to load the ivshmem driver if BAR0 size is not 256. For post-launched VM hv land ivshmem BARs are allocated by device model. For pre-launched VM hv land ivshmem BARs are allocated by acrn-config tool. Both device model and acrn-config tool should make sure that the BAR base addr are aligned to 4K at least. Tracked-On: #5717 Signed-off-by: Jian Jun Chen Reviewed-by: Fei Li Acked-by: Eddie Dong --- hypervisor/dm/vpci/ivshmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypervisor/dm/vpci/ivshmem.c b/hypervisor/dm/vpci/ivshmem.c index 87382592c..fb7f48352 100644 --- a/hypervisor/dm/vpci/ivshmem.c +++ b/hypervisor/dm/vpci/ivshmem.c @@ -26,7 +26,7 @@ #define IVSHMEM_MSIX_BAR 1U #define IVSHMEM_SHM_BAR 2U -#define IVSHMEM_MMIO_BAR_SIZE 4096UL +#define IVSHMEM_MMIO_BAR_SIZE 256UL /* The device-specific registers of ivshmem device */ #define IVSHMEM_IRQ_MASK_REG 0x0U @@ -261,7 +261,7 @@ static void ivshmem_vbar_map(struct pci_vdev *vdev, uint32_t idx) (void)memset(&ivs_dev->mmio, 0U, sizeof(ivs_dev->mmio)); register_mmio_emulation_handler(vm, ivshmem_mmio_handler, vbar->base_gpa, (vbar->base_gpa + vbar->size), vdev, false); - ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, vbar->base_gpa, vbar->size); + ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, vbar->base_gpa, round_page_up(vbar->size)); } else if ((idx == IVSHMEM_MSIX_BAR) && (vbar->base_gpa != 0UL)) { register_mmio_emulation_handler(vm, vmsix_handle_table_mmio_access, vbar->base_gpa, (vbar->base_gpa + vbar->size), vdev, false);