forked from projectacrn/acrn-hypervisor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hv: vm_event: create vm_event support
This patch creates vm_event support in HV, including: 1. Create vm_event data type. 2. Add vm_event sbuf and its initializer. The sbuf will be allocated by DM in Service VM. Its page address will then be share to HV through hypercall. 3. Add an API to send the HV generated event. Tracked-On: projectacrn#8547 Signed-off-by: Wu Zhou <wu.zhou@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
- Loading branch information
Showing
7 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2020-2023 Intel Corporation. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <util.h> | ||
#include <acrn_hv_defs.h> | ||
#include <asm/guest/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; | ||
|
||
stac(); | ||
if (sbuf != NULL) { | ||
if (sbuf->magic == SBUF_MAGIC) { | ||
vm->sw.vm_event_sbuf = sbuf; | ||
spinlock_init(&vm->vm_event_lock); | ||
ret = 0; | ||
} | ||
} | ||
clac(); | ||
|
||
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); | ||
spinlock_release(&vm->vm_event_lock); | ||
if (size_sent == sizeof(struct vm_event)) { | ||
arch_fire_hsm_interrupt(); | ||
ret = 0; | ||
} | ||
} | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (C) 2019-2023 Intel Corporation. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef VM_EVENT_H | ||
#define VM_EVENT_H | ||
|
||
#include <types.h> | ||
#include <acrn_common.h> | ||
|
||
int32_t init_vm_event(struct acrn_vm *vm, uint64_t *hva); | ||
int32_t send_vm_event(struct acrn_vm *vm, struct vm_event *event); | ||
|
||
#endif /* VM_EVENT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters