From dc77ef9e526dc1ea98111fe1d4a7e36d5632b267 Mon Sep 17 00:00:00 2001 From: Jian Jun Chen Date: Thu, 5 Aug 2021 17:24:32 +0800 Subject: [PATCH] hv: ivshmem: map SHM BAR with PAT ignored ACRN does not support the variable range vMTRR. The default memory type of vMTRR is UC. With this vMTRR emulation guest VM such as Linux refuses to map the MMIO address space as WB. In order to get better performance SHM BAR of ivshmem is mapped with PAT ignored and memory type of SHM BAR is fixed to WB. Tracked-On: #6389 Signed-off-by: Jian Jun Chen Acked-by: Eddie Dong --- hypervisor/dm/vpci/ivshmem.c | 2 +- hypervisor/include/arch/x86/asm/pgtable.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hypervisor/dm/vpci/ivshmem.c b/hypervisor/dm/vpci/ivshmem.c index 7bacf1aa2..4ba29bede 100644 --- a/hypervisor/dm/vpci/ivshmem.c +++ b/hypervisor/dm/vpci/ivshmem.c @@ -252,7 +252,7 @@ static void ivshmem_vbar_map(struct pci_vdev *vdev, uint32_t idx) if ((idx == IVSHMEM_SHM_BAR) && (vbar->base_hpa != INVALID_HPA) && (vbar->base_gpa != 0UL)) { ept_add_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, vbar->base_hpa, - vbar->base_gpa, vbar->size, EPT_RD | EPT_WR | EPT_WB); + vbar->base_gpa, vbar->size, EPT_RD | EPT_WR | EPT_WB | EPT_IGNORE_PAT); } else if ((idx == IVSHMEM_MMIO_BAR) && (vbar->base_gpa != 0UL)) { (void)memset(&ivs_dev->mmio, 0U, sizeof(ivs_dev->mmio)); register_mmio_emulation_handler(vm, ivshmem_mmio_handler, vbar->base_gpa, diff --git a/hypervisor/include/arch/x86/asm/pgtable.h b/hypervisor/include/arch/x86/asm/pgtable.h index a3d690a4e..eca2cd4ee 100644 --- a/hypervisor/include/arch/x86/asm/pgtable.h +++ b/hypervisor/include/arch/x86/asm/pgtable.h @@ -104,6 +104,11 @@ */ #define EPT_WB (6UL << EPT_MT_SHIFT) +/** + * @brief Ignore PAT memory type. + */ +#define EPT_IGNORE_PAT (1UL << 6U) + /** * @} */