dm: vm: add option to enable pmu passthrough

Add "--pmu" to enable PMU passthrough.

Tracked-On: #5132
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
This commit is contained in:
Binbin Wu 2020-08-04 10:38:49 +08:00 committed by wenlingz
parent 547428021a
commit 08c079693f
3 changed files with 13 additions and 1 deletions

View File

@ -89,6 +89,7 @@ bool lapic_pt;
bool is_rtvm;
bool is_winvm;
bool skip_pci_mem64bar_workaround = false;
bool is_pmu_pt = false;
static int guest_ncpus;
static int virtio_msix = 1;
@ -178,7 +179,8 @@ usage(int code)
" --pm_notify_channel: define the channel used to notify guest about power event\n"
" --pm_by_vuart:pty,/run/acrn/vuart_vmname or tty,/dev/ttySn\n"
" --windows: support Oracle virtio-blk, virtio-net and virtio-input devices\n"
" for windows guest with secure boot\n",
" for windows guest with secure boot\n"
" --pmu: passthrough performance monitor unit to VM\n",
progname, (int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "",
(int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "",
(int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "",
@ -737,6 +739,7 @@ enum {
CMD_OPT_PM_NOTIFY_CHANNEL,
CMD_OPT_PM_BY_VUART,
CMD_OPT_WINDOWS,
CMD_OPT_PMU,
};
static struct option long_options[] = {
@ -776,6 +779,7 @@ static struct option long_options[] = {
{"pm_notify_channel", required_argument, 0, CMD_OPT_PM_NOTIFY_CHANNEL},
{"pm_by_vuart", required_argument, 0, CMD_OPT_PM_BY_VUART},
{"windows", no_argument, 0, CMD_OPT_WINDOWS},
{"pmu", no_argument, 0, CMD_OPT_PMU},
{0, 0, 0, 0 },
};
@ -943,6 +947,9 @@ main(int argc, char *argv[])
case CMD_OPT_WINDOWS:
is_winvm = true;
break;
case CMD_OPT_PMU:
is_pmu_pt = true;
break;
case 'h':
usage(0);
default:

View File

@ -251,6 +251,10 @@ vm_create(const char *name, uint64_t req_buf, int *vcpu_num)
create_vm.vm_flag |= GUEST_FLAG_IO_COMPLETION_POLLING;
}
if (is_pmu_pt) {
create_vm.vm_flag |= GUEST_FLAG_PMU_PASSTHROUGH;
}
create_vm.req_buf = req_buf;
while (retry > 0) {
error = ioctl(ctx->fd, IC_CREATE_VM, &create_vm);

View File

@ -49,6 +49,7 @@ extern char *mac_seed;
extern bool lapic_pt;
extern bool is_rtvm;
extern bool is_winvm;
extern bool is_pmu_pt;
int vmexit_task_switch(struct vmctx *ctx, struct vhm_request *vhm_req,
int *vcpu);