mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +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:
parent
088cd62d8b
commit
d6f563c4eb
@ -306,6 +306,7 @@ VP_DM_C_SRCS += dm/vpci/vdev.c
|
||||
VP_DM_C_SRCS += dm/vpci/vpci.c
|
||||
VP_DM_C_SRCS += dm/vpci/vhostbridge.c
|
||||
VP_DM_C_SRCS += dm/vpci/vpci_bridge.c
|
||||
VP_DM_C_SRCS += dm/vpci/ivshmem.c
|
||||
VP_DM_C_SRCS += dm/vpci/pci_pt.c
|
||||
VP_DM_C_SRCS += dm/vpci/vmsi.c
|
||||
VP_DM_C_SRCS += dm/vpci/vmsix.c
|
||||
|
@ -336,3 +336,11 @@ config ENFORCE_TURNOFF_AC
|
||||
help
|
||||
If CPU has #AC for split-locked access, HV enable it and VMs can't disable.
|
||||
Set this to enforce turn off that #AC, for community developer only.
|
||||
|
||||
config IVSHMEM_ENABLED
|
||||
bool "Enable ivshmem inter-vm communication based on hypervisor shared memory"
|
||||
default n
|
||||
help
|
||||
Ivshmem shared memory is located in the hypervisor, it can provide multiple
|
||||
memory regions as communication channels between pre-launched or post-launched
|
||||
VMs.
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <vboot.h>
|
||||
#include <sgx.h>
|
||||
#include <uart16550.h>
|
||||
#include <ivshmem.h>
|
||||
|
||||
#define CPU_UP_TIMEOUT 100U /* millisecond */
|
||||
#define CPU_DOWN_TIMEOUT 100U /* millisecond */
|
||||
@ -244,6 +245,9 @@ void init_pcpu_post(uint16_t pcpu_id)
|
||||
}
|
||||
|
||||
hv_access_memory_region_update(get_mmcfg_base(), PCI_MMCONFIG_SIZE);
|
||||
#ifdef CONFIG_IVSHMEM_ENABLED
|
||||
init_ivshmem_shared_memory();
|
||||
#endif
|
||||
init_pci_pdev_list(); /* init_iommu must come before this */
|
||||
ptdev_init();
|
||||
|
||||
|
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
|
28
hypervisor/include/dm/ivshmem.h
Normal file
28
hypervisor/include/dm/ivshmem.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef IVSHMEM_H
|
||||
#define IVSHMEM_H
|
||||
|
||||
#ifdef CONFIG_IVSHMEM_ENABLED
|
||||
struct ivshmem_shm_region {
|
||||
char name[32];
|
||||
uint64_t hpa;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize ivshmem shared memory regions
|
||||
*
|
||||
* Initialize ivshmem shared memory regions based on user configuration.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void init_ivshmem_shared_memory(void);
|
||||
|
||||
#endif /* CONFIG_IVSHMEM_ENABLED */
|
||||
|
||||
#endif /* IVSHMEM_H */
|
Loading…
Reference in New Issue
Block a user