From 78f42ca16b626a8bfe33f4f9e86a38582d547586 Mon Sep 17 00:00:00 2001 From: Qian Wang Date: Mon, 21 Sep 2020 10:30:09 +0800 Subject: [PATCH] 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 --- devicemodel/core/main.c | 7 ++++--- devicemodel/core/sw_load_common.c | 3 +++ devicemodel/hw/platform/acpi/acpi.c | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index 1a70a0bef..e1bea1ea5 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -145,7 +145,7 @@ usage(int code) " %*s [--vtpm2 sock_path] [--virtio_poll interval] [--mac_seed seed_string]\n" " %*s [--vmcfg sub_options] [--dump vm_idx] [--debugexit] \n" " %*s [--logger-setting param_setting] [--pm_notify_channel]\n" - " %*s [--psram psram_size]\n" + " %*s [--psram]\n" " %*s [--pm_by_vuart vuart_node] \n" " -A: create ACPI tables\n" " -B: bootargs for kernel\n" @@ -168,7 +168,7 @@ usage(int code) " --dump: show build-in VM configurations\n" #endif " --vsbl: vsbl file path\n" - " --psram: 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" " --cpu_affinity: list of pCPUs assigned to this VM\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}, {"lapic_pt", no_argument, 0, CMD_OPT_LAPIC_PT}, {"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}, {"pm_notify_channel", required_argument, 0, CMD_OPT_PM_NOTIFY_CHANNEL}, {"pm_by_vuart", required_argument, 0, CMD_OPT_PM_BY_VUART}, @@ -939,6 +939,7 @@ main(int argc, char *argv[]) is_rtvm = true; break; case CMD_OPT_PSRAM: + /* TODO: we need to support parameter to specify pSRAM size in the future */ pt_ptct = true; break; case CMD_OPT_ACPIDEV_PT: diff --git a/devicemodel/core/sw_load_common.c b/devicemodel/core/sw_load_common.c index 1f7588a54..860289c3b 100644 --- a/devicemodel/core/sw_load_common.c +++ b/devicemodel/core/sw_load_common.c @@ -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 only when ctx->lowmem is higher than PSRAM area. 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; + } /* remove [5GB, highmem) if it's empty */ diff --git a/devicemodel/hw/platform/acpi/acpi.c b/devicemodel/hw/platform/acpi/acpi.c index e0528607e..635d7731e 100644 --- a/devicemodel/hw/platform/acpi/acpi.c +++ b/devicemodel/hw/platform/acpi/acpi.c @@ -1093,8 +1093,9 @@ int create_and_inject_vptct(struct vmctx *ctx) .type = VM_MMIO, .gpa = PSRAM_BASE_GPA, .hpa = PSRAM_BASE_HPA, - /* TODO: the .len should be set as the psram_size passed-in via the DM argument "psram "*/ - .len = 0x208000UL, + /* Extra 32 KB is for PTCM binary image*/ + /* 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 };