mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-15 13:59:18 +00:00
hv: implement ivshmem memory regions initialization
The ivshmem memory regions use the memory of the hypervisor and they are continuous and page aligned. this patch is used to initialize each memory region hpa. v2: 1) if CONFIG_IVSHMEM_SHARED_MEMORY_ENABLED is not defined, the entire code of ivshmem will not be compiled. 2) change ivshmem shared memory unit from byte to page to avoid misconfiguration. 3) add ivshmem configuration and vm configuration references v3: 1) change CONFIG_IVSHMEM_SHARED_MEMORY_ENABLED to CONFIG_IVSHMEM_ENABLED 2) remove the ivshmem configuration sample, offline tool provides default ivshmem configuration. 3) refine code style. v4: 1) make ivshmem_base 2M aligned. Tracked-On: #4853 Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
29
hypervisor/dm/vpci/ivshmem.c
Normal file
29
hypervisor/dm/vpci/ivshmem.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_IVSHMEM_ENABLED
|
||||
#include <vm.h>
|
||||
#include <mmu.h>
|
||||
#include <ept.h>
|
||||
#include <logmsg.h>
|
||||
#include <ivshmem.h>
|
||||
#include "vpci_priv.h"
|
||||
|
||||
/* IVSHMEM_SHM_SIZE is provided by offline tool */
|
||||
static uint8_t ivshmem_base[IVSHMEM_SHM_SIZE] __aligned(PDE_SIZE);
|
||||
|
||||
void init_ivshmem_shared_memory()
|
||||
{
|
||||
uint32_t i;
|
||||
uint64_t addr = hva2hpa(&ivshmem_base);
|
||||
|
||||
for (i = 0U; i < ARRAY_SIZE(mem_regions); i++) {
|
||||
mem_regions[i].hpa = addr;
|
||||
addr += mem_regions[i].size;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user