Skip to content

Commit c873d60

Browse files
lyan3wenlingz
authored andcommitted
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 <like.yan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 8925da6 commit c873d60

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

devicemodel/core/main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ usage(int code)
171171
" --intr_monitor: enable interrupt storm monitor\n"
172172
" its params: threshold/s,probe-period(s),delay_time(ms),delay_duration(ms)\n"
173173
" --virtio_poll: enable virtio poll mode with poll interval with ns\n"
174-
" --vtpm2: Virtual TPM2 args: sock_path=$PATH_OF_SWTPM_SOCKET\n",
174+
" --vtpm2: Virtual TPM2 args: sock_path=$PATH_OF_SWTPM_SOCKET\n"
175+
" --lapic_pt: enable local apic passthrough\n",
175176
progname, (int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "",
176177
(int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "",
177178
(int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "");
@@ -706,6 +707,7 @@ enum {
706707
CMD_OPT_DUMP,
707708
CMD_OPT_INTR_MONITOR,
708709
CMD_OPT_VTPM2,
710+
CMD_OPT_LAPIC_PT,
709711
};
710712

711713
static struct option long_options[] = {
@@ -744,6 +746,7 @@ static struct option long_options[] = {
744746
{"debugexit", no_argument, 0, CMD_OPT_DEBUGEXIT},
745747
{"intr_monitor", required_argument, 0, CMD_OPT_INTR_MONITOR},
746748
{"vtpm2", required_argument, 0, CMD_OPT_VTPM2},
749+
{"lapic_pt", no_argument, 0, CMD_OPT_LAPIC_PT},
747750
{0, 0, 0, 0 },
748751
};
749752

@@ -887,6 +890,9 @@ dm_run(int argc, char *argv[])
887890
case CMD_OPT_DEBUGEXIT:
888891
debugexit_enabled = true;
889892
break;
893+
case CMD_OPT_LAPIC_PT:
894+
lapic_pt = true;
895+
break;
890896
case CMD_OPT_VTPM2:
891897
if (acrn_parse_vtpm2(optarg) != 0) {
892898
errx(EX_USAGE, "invalid vtpm2 param %s", optarg);

devicemodel/core/vmmapi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ vm_create(const char *name, uint64_t req_buf)
138138
else
139139
create_vm.vm_flag &= (~SECURE_WORLD_ENABLED);
140140

141+
if (lapic_pt) {
142+
create_vm.vm_flag |= LAPIC_PASSTHROUGH;
143+
create_vm.vm_flag |= IOREQ_COMPLETION_POLLING;
144+
} else {
145+
create_vm.vm_flag &= (~LAPIC_PASSTHROUGH);
146+
create_vm.vm_flag &= (~IOREQ_COMPLETION_POLLING);
147+
}
148+
141149
create_vm.req_buf = req_buf;
142150
while (retry > 0) {
143151
error = ioctl(ctx->fd, IC_CREATE_VM, &create_vm);

devicemodel/include/public/acrn_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
#endif
6767

6868
/* Generic VM flags from guest OS */
69-
#define SECURE_WORLD_ENABLED (1UL<<0) /* Whether secure world is enabled */
69+
#define SECURE_WORLD_ENABLED (1UL << 0U) /* Whether secure world is enabled */
70+
#define LAPIC_PASSTHROUGH (1UL << 1U) /* Whether LAPIC is passed through */
71+
#define IOREQ_COMPLETION_POLLING (1UL << 2U) /* Whether need hypervisor poll IO completion */
7072

7173
/**
7274
* @brief Hypercall

0 commit comments

Comments
 (0)