// SPDX-License-Identifier: GPL-2.0 /* * A sample program to run a User VM on the ACRN hypervisor * * This sample runs in a Service VM, which is a privileged VM of ACRN. * CONFIG_ACRN_HSM needs to be enabled in the Service VM. * * Guest VM code in guest16.s will be executed after the VM launched. * * Copyright (C) 2020 Intel Corporation. All rights reserved.
*/ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <signal.h> #include <sys/ioctl.h> #include <linux/acrn.h>
ret = ioctl(hsm_fd, ACRN_IOCTL_SET_VCPU_REGS, ®s);
printf("Set up VM BSP registers! [%d]\n", ret);
/* create an ioreq client for this VM */
ret = ioctl(hsm_fd, ACRN_IOCTL_CREATE_IOREQ_CLIENT, 0);
printf("Created IO request client! [%d]\n", ret);
/* run vm */
ret = ioctl(hsm_fd, ACRN_IOCTL_START_VM, vmid);
printf("Start VM! [%d]\n", ret);
signal(SIGINT, vm_exit); while (is_running) {
ret = ioctl(hsm_fd, ACRN_IOCTL_ATTACH_IOREQ_CLIENT, 0);
for (vcpu_id = 0; vcpu_id < vcpu_num; vcpu_id++) {
io_req = &io_req_buf[vcpu_id]; if ((__sync_add_and_fetch(&io_req->processed, 0) == ACRN_IOREQ_STATE_PROCESSING)
&& (!io_req->kernel_handled)) if (io_req->type == ACRN_IOREQ_TYPE_PORTIO) { int bytes, port, in;
port = io_req->reqs.pio_request.address;
bytes = io_req->reqs.pio_request.size;
in = (io_req->reqs.pio_request.direction == ACRN_IOREQ_DIR_READ);
printf("Guest VM %s PIO[%x] with size[%x]\n", in ? "read" : "write", port, bytes);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.