From c873d60ae228c3e9ab0a04831c4fbcb62e2fe4c6 Mon Sep 17 00:00:00 2001 From: "Yan, Like" Date: Tue, 22 Jan 2019 17:00:13 +0800 Subject: [PATCH] dm: add option "lapic_pt" to create VM for realtime scenarios New option "--lapic_pt" added to create VM with local apic passthrough, for realtime scenarios. When the option is set, a VM is created with LAPIC_PASSTHROUGH. The option is not set by default. Tracked-On: #2351 Signed-off-by: Yan, Like Acked-by: Eddie Dong Acked-by: Anthony Xu --- devicemodel/core/main.c | 8 +++++++- devicemodel/core/vmmapi.c | 8 ++++++++ devicemodel/include/public/acrn_common.h | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index 758894a20..e3cfefca2 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -171,7 +171,8 @@ usage(int code) " --intr_monitor: enable interrupt storm monitor\n" " its params: threshold/s,probe-period(s),delay_time(ms),delay_duration(ms)\n" " --virtio_poll: enable virtio poll mode with poll interval with ns\n" - " --vtpm2: Virtual TPM2 args: sock_path=$PATH_OF_SWTPM_SOCKET\n", + " --vtpm2: Virtual TPM2 args: sock_path=$PATH_OF_SWTPM_SOCKET\n" + " --lapic_pt: enable local apic passthrough\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), ""); @@ -706,6 +707,7 @@ enum { CMD_OPT_DUMP, CMD_OPT_INTR_MONITOR, CMD_OPT_VTPM2, + CMD_OPT_LAPIC_PT, }; static struct option long_options[] = { @@ -744,6 +746,7 @@ static struct option long_options[] = { {"debugexit", no_argument, 0, CMD_OPT_DEBUGEXIT}, {"intr_monitor", required_argument, 0, CMD_OPT_INTR_MONITOR}, {"vtpm2", required_argument, 0, CMD_OPT_VTPM2}, + {"lapic_pt", no_argument, 0, CMD_OPT_LAPIC_PT}, {0, 0, 0, 0 }, }; @@ -887,6 +890,9 @@ dm_run(int argc, char *argv[]) case CMD_OPT_DEBUGEXIT: debugexit_enabled = true; break; + case CMD_OPT_LAPIC_PT: + lapic_pt = true; + break; case CMD_OPT_VTPM2: if (acrn_parse_vtpm2(optarg) != 0) { errx(EX_USAGE, "invalid vtpm2 param %s", optarg); diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index f6eee61fa..8753c95b4 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -138,6 +138,14 @@ vm_create(const char *name, uint64_t req_buf) else create_vm.vm_flag &= (~SECURE_WORLD_ENABLED); + if (lapic_pt) { + create_vm.vm_flag |= LAPIC_PASSTHROUGH; + create_vm.vm_flag |= IOREQ_COMPLETION_POLLING; + } else { + create_vm.vm_flag &= (~LAPIC_PASSTHROUGH); + create_vm.vm_flag &= (~IOREQ_COMPLETION_POLLING); + } + create_vm.req_buf = req_buf; while (retry > 0) { error = ioctl(ctx->fd, IC_CREATE_VM, &create_vm); diff --git a/devicemodel/include/public/acrn_common.h b/devicemodel/include/public/acrn_common.h index a49814a4e..9901c16d3 100644 --- a/devicemodel/include/public/acrn_common.h +++ b/devicemodel/include/public/acrn_common.h @@ -66,7 +66,9 @@ #endif /* Generic VM flags from guest OS */ -#define SECURE_WORLD_ENABLED (1UL<<0) /* Whether secure world is enabled */ +#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */ +#define LAPIC_PASSTHROUGH (1UL << 1U) /* Whether LAPIC is passed through */ +#define IOREQ_COMPLETION_POLLING (1UL << 2U) /* Whether need hypervisor poll IO completion */ /** * @brief Hypercall