mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-18 00:17:19 +00:00
This commit moves struct acrn_vm under common header vm.h, and move some x86-specific members of struct acrn_vm into arch_vm. This commit focuses on struct cleanup only. API cleanup will be in future patch series. The affected members are: e820_entry_num e820_entries wire_mode wbinvd_lock vlapic_mode_lock vcpuid_entry_nr vcpuid_level vcpuid_xlevel vcpuid_entries reset_control pm sworld_control sworld_snapshot intr_inject_delay_delta Moved to common vm.h: ept_lock -> rename to stg2pt_lock ept_pgtable -> rename to stg2_pgtable nworld_eptp -> rename to root_stg2ptp emul_mmio_lock nr_emul_mmio_regions emul_mmio emul_pio To avoid circular dependency, some in-header helpers are also moved into common vm.h. Tracked-On: #8830 Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Reviewed-by: Fei Li <fei1.li@intel.com> Acked-by: Wang Yu1 <yu1.wang@intel.com>
49 lines
1007 B
C
49 lines
1007 B
C
/*
|
|
* Copyright (C) 2020-2023 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <errno.h>
|
|
#include <util.h>
|
|
#include <acrn_hv_defs.h>
|
|
#include <vm.h>
|
|
#include <vm_event.h>
|
|
#include <sbuf.h>
|
|
|
|
int32_t init_vm_event(struct acrn_vm *vm, uint64_t *hva)
|
|
{
|
|
struct shared_buf *sbuf = (struct shared_buf *)hva;
|
|
int ret = -1;
|
|
|
|
pre_user_access();
|
|
if (sbuf != NULL) {
|
|
if (sbuf->magic == SBUF_MAGIC) {
|
|
vm->sw.vm_event_sbuf = sbuf;
|
|
spinlock_init(&vm->vm_event_lock);
|
|
ret = 0;
|
|
}
|
|
}
|
|
post_user_access();
|
|
|
|
return ret;
|
|
}
|
|
|
|
int32_t send_vm_event(struct acrn_vm *vm, struct vm_event *event)
|
|
{
|
|
struct shared_buf *sbuf = (struct shared_buf *)vm->sw.vm_event_sbuf;
|
|
int32_t ret = -ENODEV;
|
|
uint32_t size_sent;
|
|
|
|
if (sbuf != NULL) {
|
|
spinlock_obtain(&vm->vm_event_lock);
|
|
size_sent = sbuf_put(sbuf, (uint8_t *)event, sizeof(*event));
|
|
spinlock_release(&vm->vm_event_lock);
|
|
if (size_sent == sizeof(struct vm_event)) {
|
|
arch_fire_hsm_interrupt();
|
|
ret = 0;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|