mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-12 12:30:08 +00:00
dm: add support of high MMIO mapping
1G PCI hole is added just after 4G address which is used as the PCI high MMIO address space. Guest high memory is mapped from 5G address for both EPT and device model user space address. Guest e820 table and API vm_map_gpa are updated accordingly. Tracked-On: #2577 Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
@@ -652,14 +652,7 @@ int hugetlb_setup_memory(struct vmctx *ctx)
|
||||
ctx->highmem =
|
||||
ALIGN_DOWN(ctx->highmem, hugetlb_priv[HUGETLB_LV1].pg_size);
|
||||
|
||||
/*
|
||||
* High BIOS resides right below 4GB.
|
||||
* Therefore, at least 4GB of memory space is needed.
|
||||
*/
|
||||
if (ctx->biosmem > 0 || ctx->highmem > 0)
|
||||
total_size = 4 * GB + ctx->highmem;
|
||||
else
|
||||
total_size = ctx->lowmem;
|
||||
total_size = ctx->highmem_gpa_base + ctx->highmem;
|
||||
|
||||
/* check & set hugetlb level memory size for lowmem/biosmem/highmem */
|
||||
lowmem = ctx->lowmem;
|
||||
@@ -735,7 +728,8 @@ int hugetlb_setup_memory(struct vmctx *ctx)
|
||||
}
|
||||
|
||||
/* mmap highmem */
|
||||
if (mmap_hugetlbfs(ctx, 4 * GB, get_highmem_param, adj_highmem_param) < 0) {
|
||||
if (mmap_hugetlbfs(ctx, ctx->highmem_gpa_base,
|
||||
get_highmem_param, adj_highmem_param) < 0) {
|
||||
perror("highmem mmap failed");
|
||||
goto err;
|
||||
}
|
||||
@@ -772,8 +766,9 @@ int hugetlb_setup_memory(struct vmctx *ctx)
|
||||
|
||||
/* map ept for highmem */
|
||||
if (ctx->highmem > 0) {
|
||||
if (vm_map_memseg_vma(ctx, ctx->highmem, 4 * GB,
|
||||
(uint64_t)(ctx->baseaddr + 4 * GB), PROT_ALL) < 0)
|
||||
if (vm_map_memseg_vma(ctx, ctx->highmem, ctx->highmem_gpa_base,
|
||||
(uint64_t)(ctx->baseaddr + ctx->highmem_gpa_base),
|
||||
PROT_ALL) < 0)
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@@ -522,7 +522,7 @@ static struct smbios_template_entry smbios_template[] = {
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static uint64_t guest_lomem, guest_himem;
|
||||
static uint64_t guest_lomem, guest_himem, guest_highmem_base;
|
||||
static uint16_t type16_handle;
|
||||
|
||||
static int
|
||||
@@ -709,7 +709,7 @@ smbios_type19_initializer(struct smbios_structure *template_entry,
|
||||
curaddr, endaddr, n, size);
|
||||
type19 = (struct smbios_table_type19 *)curaddr;
|
||||
type19->arrayhand = type16_handle;
|
||||
type19->xsaddr = 4*GB;
|
||||
type19->xsaddr = guest_highmem_base;
|
||||
type19->xeaddr = guest_himem;
|
||||
}
|
||||
|
||||
@@ -767,6 +767,7 @@ smbios_build(struct vmctx *ctx)
|
||||
|
||||
guest_lomem = vm_get_lowmem_size(ctx);
|
||||
guest_himem = vm_get_highmem_size(ctx);
|
||||
guest_highmem_base = ctx->highmem_gpa_base;
|
||||
|
||||
startaddr = paddr_guest2host(ctx, SMBIOS_BASE, SMBIOS_MAX_LENGTH);
|
||||
if (startaddr == NULL) {
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "vmmapi.h"
|
||||
#include "sw_load.h"
|
||||
#include "dm.h"
|
||||
#include "pci_core.h"
|
||||
|
||||
int with_bootargs;
|
||||
static char bootargs[STR_LEN];
|
||||
@@ -56,7 +57,8 @@ static char bootargs[STR_LEN];
|
||||
* 3: lowmem - bff_fffff (reserved) 0xc00_00000-lowmem
|
||||
* 4: 0xc00_00000 - dff_fffff PCI hole 512MB
|
||||
* 5: 0xe00_00000 - fff_fffff (reserved) 512MB
|
||||
* 6: 1_000_00000 - highmem RAM highmem-4G
|
||||
* 6: 1_000_00000 - 1_400_00000 PCI hole 1G
|
||||
* 7: 1_400_00000 - highmem RAM highmem-5G
|
||||
*/
|
||||
const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = {
|
||||
{ /* 0 to mptable/smbios/acpi */
|
||||
@@ -89,8 +91,14 @@ const struct e820_entry e820_default_entries[NUM_E820_ENTRIES] = {
|
||||
.type = E820_TYPE_RESERVED
|
||||
},
|
||||
|
||||
{ /* 4G to 5G */
|
||||
.baseaddr = PCI_EMUL_MEMBASE64,
|
||||
.length = PCI_EMUL_MEMLIMIT64 - PCI_EMUL_MEMBASE64,
|
||||
.type = E820_TYPE_RESERVED
|
||||
},
|
||||
|
||||
{
|
||||
.baseaddr = 0x100000000,
|
||||
.baseaddr = PCI_EMUL_MEMLIMIT64,
|
||||
.length = 0x000100000,
|
||||
.type = E820_TYPE_RESERVED
|
||||
},
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include "mevent.h"
|
||||
|
||||
#include "dm.h"
|
||||
#include "pci_core.h"
|
||||
|
||||
#define MAP_NOCORE 0
|
||||
#define MAP_ALIGNED_SUPER 0
|
||||
@@ -129,6 +130,7 @@ vm_create(const char *name, uint64_t req_buf)
|
||||
|
||||
ctx->fd = devfd;
|
||||
ctx->lowmem_limit = 2 * GB;
|
||||
ctx->highmem_gpa_base = PCI_EMUL_MEMLIMIT64;
|
||||
ctx->name = (char *)(ctx + 1);
|
||||
strncpy(ctx->name, name, strnlen(name, PATH_MAX) + 1);
|
||||
|
||||
@@ -327,7 +329,8 @@ vm_unsetup_memory(struct vmctx *ctx)
|
||||
*/
|
||||
bzero((void *)ctx->baseaddr, ctx->lowmem);
|
||||
if (ctx->highmem > 0) {
|
||||
bzero((void *)(ctx->baseaddr + 4 * GB), ctx->highmem);
|
||||
bzero((void *)(ctx->baseaddr + ctx->highmem_gpa_base),
|
||||
ctx->highmem);
|
||||
}
|
||||
|
||||
hugetlb_unsetup_memory(ctx);
|
||||
@@ -351,10 +354,10 @@ vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len)
|
||||
}
|
||||
|
||||
if (ctx->highmem > 0) {
|
||||
if (gaddr >= 4*GB) {
|
||||
if (gaddr < 4*GB + ctx->highmem &&
|
||||
if (gaddr >= ctx->highmem_gpa_base) {
|
||||
if (gaddr < ctx->highmem_gpa_base + ctx->highmem &&
|
||||
len <= ctx->highmem &&
|
||||
gaddr + len <= 4*GB + ctx->highmem)
|
||||
gaddr + len <= ctx->highmem_gpa_base + ctx->highmem)
|
||||
return (ctx->baseaddr + gaddr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user