diff --git a/hypervisor/arch/x86/guest/ve820.c b/hypervisor/arch/x86/guest/ve820.c index 472ffec84..b300f9b63 100644 --- a/hypervisor/arch/x86/guest/ve820.c +++ b/hypervisor/arch/x86/guest/ve820.c @@ -211,12 +211,12 @@ static const struct e820_entry pre_ve820_template[E820_MAX_ENTRIES] = { }, { /* ACPI Reclaim */ .baseaddr = VIRT_ACPI_DATA_ADDR,/* consecutive from 0x7fe00000UL */ - .length = (960U * MEM_1K), /* 960KB */ + .length = VIRT_ACPI_DATA_LEN, .type = E820_TYPE_ACPI_RECLAIM }, { /* ACPI NVS */ .baseaddr = VIRT_ACPI_NVS_ADDR, /* consecutive after ACPI Reclaim */ - .length = MEM_1M, /* only the first 64KB is used for NVS */ + .length = VIRT_ACPI_NVS_LEN, .type = E820_TYPE_ACPI_NVS }, { /* 32bit PCI hole */ @@ -250,8 +250,13 @@ static inline uint64_t add_ram_entry(struct e820_entry *entry, uint64_t gpa, uin * Software SRAM segment rather than hpa1. * entry4: usable, the part2 of hpa1 in lowmem, from the ceil of Software SRAM segment, * and up to 2G-1M. - * entry5: ACPI Reclaim from 0x7ff00000 to 0x7ffeffff - * entry6: ACPI NVS from 0x7fff0000 to 0x7fffffff + * entry5: ACPI Reclaim from 0x7fe00000 to 0x7fefffff (1M) + * entry6: ACPI NVS from 0x7ff00000 to 0x7fffffff (1M) + * Currently this is used by: + * a) first 64k reserved + * if CONFIG_SECURITY_VM_FIXUP enabled, + * b) TPM2 event log region (if platform supports TPM2 eventlog) from 0x7ffb0000 to 0x7fffffff + * c) SMBIOS table in between 64k and 0xb0000 * entry7: reserved for 32bit PCI hole from 0x80000000 to 0xffffffff * (entry8): usable for * a) hpa1_hi, if hpa1 > 2GB - PRE_RTVM_SW_SRAM_MAX_SIZE @@ -271,7 +276,7 @@ static inline uint64_t add_ram_entry(struct e820_entry *entry, uint64_t gpa, uin |<---Software SRAM--->| |<-----hpa1_low_part2--->| |<---Non-mapped hole (if there is)-->| - |<---1M ACPI NVS/DATA--->| + |<---(1M + 1M) ACPI NVS/DATA--->| */ void create_prelaunched_vm_e820(struct acrn_vm *vm) { @@ -293,18 +298,18 @@ void create_prelaunched_vm_e820(struct acrn_vm *vm) hpa1_hi_size = vm_config->memory.size - lowmem_max_length; gpa_start = add_ram_entry((vm->e820_entries + entry_idx), gpa_start, hpa1_hi_size); entry_idx++; - } else if (vm_config->memory.size <= (MEM_1M + hpa1_part1_max_length + MEM_1M)) { + } else if (vm_config->memory.size <= (MEM_1M + hpa1_part1_max_length + VIRT_ACPI_DATA_LEN + VIRT_ACPI_NVS_LEN)) { /* * In this case, hpa1 is only enough for the first - * 1M + part1 + last 1M (ACPI NVS/DATA), so part2 will be empty. - * Below 'MEM_2M' includes the first and last 1M + * 1M + part1 + last (1M + 1M) (ACPI NVS/DATA), so part2 will be empty. */ - vm->e820_entries[ENTRY_HPA1_LOW_PART1].length = vm_config->memory.size - MEM_2M; + vm->e820_entries[ENTRY_HPA1_LOW_PART1].length = + vm_config->memory.size - MEM_1M - VIRT_ACPI_DATA_LEN - VIRT_ACPI_NVS_LEN; vm->e820_entries[ENTRY_HPA1_LOW_PART2].length = 0; } else { /* Otherwise, part2 is not empty. */ vm->e820_entries[ENTRY_HPA1_LOW_PART2].length = - vm_config->memory.size - PRE_RTVM_SW_SRAM_BASE_GPA - MEM_1M; + vm_config->memory.size - PRE_RTVM_SW_SRAM_BASE_GPA - VIRT_ACPI_DATA_LEN - VIRT_ACPI_NVS_LEN; /* need to set gpa_start for hpa2 */ } diff --git a/hypervisor/include/dm/vacpi.h b/hypervisor/include/dm/vacpi.h index 9ea899678..0266b82a7 100644 --- a/hypervisor/include/dm/vacpi.h +++ b/hypervisor/include/dm/vacpi.h @@ -17,8 +17,11 @@ * table which at GPA 0x7fe00080; * The module file should be generated by acrn-config tool; */ -#define VIRT_ACPI_DATA_ADDR 0x7fe00000UL -#define VIRT_ACPI_NVS_ADDR 0x7ff00000UL +#define VIRT_ACPI_DATA_LEN MEM_1M +#define VIRT_ACPI_NVS_LEN MEM_1M +/* Currently ACPI NVS start addr is presumed to be consecutive with ACPI DATA area right below 0x80000000 */ +#define VIRT_ACPI_NVS_ADDR (0x80000000UL - VIRT_ACPI_NVS_LEN) +#define VIRT_ACPI_DATA_ADDR (VIRT_ACPI_NVS_ADDR - VIRT_ACPI_DATA_LEN) #define VIRT_RSDP_ADDR 0x000f2400UL #define VIRT_XSDT_ADDR 0x7fe00080UL