dm: bug fix & code refine

1. Fix the bug that RTVM may fail to launch
when its allocated memory is too little and
makes use of pSRAM. Now we added an assert
to inform users to allocate enough memory
for RTVM.
2. Refined some codes.

Tracked-On: #5330

Signed-off-by: Qian Wang <qian1.wang@intel.com>
This commit is contained in:
Qian Wang 2020-09-21 10:30:09 +08:00 committed by wenlingz
parent 793b99e3f6
commit 78f42ca16b
3 changed files with 10 additions and 5 deletions

View File

@ -145,7 +145,7 @@ usage(int code)
" %*s [--vtpm2 sock_path] [--virtio_poll interval] [--mac_seed seed_string]\n" " %*s [--vtpm2 sock_path] [--virtio_poll interval] [--mac_seed seed_string]\n"
" %*s [--vmcfg sub_options] [--dump vm_idx] [--debugexit] \n" " %*s [--vmcfg sub_options] [--dump vm_idx] [--debugexit] \n"
" %*s [--logger-setting param_setting] [--pm_notify_channel]\n" " %*s [--logger-setting param_setting] [--pm_notify_channel]\n"
" %*s [--psram psram_size]\n" " %*s [--psram]\n"
" %*s [--pm_by_vuart vuart_node] <vm>\n" " %*s [--pm_by_vuart vuart_node] <vm>\n"
" -A: create ACPI tables\n" " -A: create ACPI tables\n"
" -B: bootargs for kernel\n" " -B: bootargs for kernel\n"
@ -168,7 +168,7 @@ usage(int code)
" --dump: show build-in VM configurations\n" " --dump: show build-in VM configurations\n"
#endif #endif
" --vsbl: vsbl file path\n" " --vsbl: vsbl file path\n"
" --psram: <psram_size in MB> Allocate pSRAM of psram_size MB for this VM. This VM must be an RTVM\n" " --psram: Enable support for pSRAM for this VM. This VM must be an RTVM\n"
" --ovmf: ovmf file path\n" " --ovmf: ovmf file path\n"
" --cpu_affinity: list of pCPUs assigned to this VM\n" " --cpu_affinity: list of pCPUs assigned to this VM\n"
" --part_info: guest partition info file path\n" " --part_info: guest partition info file path\n"
@ -794,7 +794,7 @@ static struct option long_options[] = {
{"vtpm2", required_argument, 0, CMD_OPT_VTPM2}, {"vtpm2", required_argument, 0, CMD_OPT_VTPM2},
{"lapic_pt", no_argument, 0, CMD_OPT_LAPIC_PT}, {"lapic_pt", no_argument, 0, CMD_OPT_LAPIC_PT},
{"rtvm", no_argument, 0, CMD_OPT_RTVM}, {"rtvm", no_argument, 0, CMD_OPT_RTVM},
{"psram", no_argument, 0, CMD_OPT_PSRAM}, /* TODO: Need argument*/ {"psram", no_argument, 0, CMD_OPT_PSRAM},
{"logger_setting", required_argument, 0, CMD_OPT_LOGGER_SETTING}, {"logger_setting", required_argument, 0, CMD_OPT_LOGGER_SETTING},
{"pm_notify_channel", required_argument, 0, CMD_OPT_PM_NOTIFY_CHANNEL}, {"pm_notify_channel", required_argument, 0, CMD_OPT_PM_NOTIFY_CHANNEL},
{"pm_by_vuart", required_argument, 0, CMD_OPT_PM_BY_VUART}, {"pm_by_vuart", required_argument, 0, CMD_OPT_PM_BY_VUART},
@ -939,6 +939,7 @@ main(int argc, char *argv[])
is_rtvm = true; is_rtvm = true;
break; break;
case CMD_OPT_PSRAM: case CMD_OPT_PSRAM:
/* TODO: we need to support parameter to specify pSRAM size in the future */
pt_ptct = true; pt_ptct = true;
break; break;
case CMD_OPT_ACPIDEV_PT: case CMD_OPT_ACPIDEV_PT:

View File

@ -271,7 +271,10 @@ acrn_create_e820_table(struct vmctx *ctx, struct e820_entry *e820)
/* Fix-Me: e820[LOWRAM_E820_ENTRY+2] can be used as RAM /* Fix-Me: e820[LOWRAM_E820_ENTRY+2] can be used as RAM
only when ctx->lowmem is higher than PSRAM area. only when ctx->lowmem is higher than PSRAM area.
also, the length should be adjusted to ctx->lowmem-baseaddr */ also, the length should be adjusted to ctx->lowmem-baseaddr */
/* TODO: this is a temporary workaround. needs further refine to remove the >=2G restriction */
assert(ctx->lowmem >= 2 * GB);
e820[LOWRAM_E820_ENTRY+2].type = E820_TYPE_RAM; e820[LOWRAM_E820_ENTRY+2].type = E820_TYPE_RAM;
} }
/* remove [5GB, highmem) if it's empty */ /* remove [5GB, highmem) if it's empty */

View File

@ -1093,8 +1093,9 @@ int create_and_inject_vptct(struct vmctx *ctx)
.type = VM_MMIO, .type = VM_MMIO,
.gpa = PSRAM_BASE_GPA, .gpa = PSRAM_BASE_GPA,
.hpa = PSRAM_BASE_HPA, .hpa = PSRAM_BASE_HPA,
/* TODO: the .len should be set as the psram_size passed-in via the DM argument "psram <psram_size>"*/ /* Extra 32 KB is for PTCM binary image*/
.len = 0x208000UL, /* TODO: .len should be psram_size+32kb. we need to modify guest E820 to adapt to real config */
.len = 0x400000U + 32 * KB,
.prot = PROT_ALL .prot = PROT_ALL
}; };