hugetlb: add ept map memseg support

adding API vm_map_memseg_vma() which using ioctl IC_SET_MEMSEG call
into VHM for futher mem(ept) mapping, based on user vma information.

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
This commit is contained in:
Jason Chen CJ
2018-01-30 22:58:40 +08:00
committed by Jack Ren
parent 4cad694be2
commit 25ef14edac
4 changed files with 52 additions and 11 deletions

View File

@@ -487,6 +487,18 @@ int hugetlb_setup_memory(struct vmctx *ctx)
}
printf("total_size 0x%lx\n\n", total_size);
/* map ept for lowmem*/
if (vm_map_memseg_vma(ctx, ctx->lowmem, 0,
(uint64_t)ctx->baseaddr, PROT_ALL) < 0)
goto err;
/* 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)
goto err;
}
return 0;
err:

View File

@@ -68,9 +68,6 @@
*/
#define VM_MMAP_GUARD_SIZE (4 * MB)
#define PROT_RW (PROT_READ | PROT_WRITE)
#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
#define SUPPORT_VHM_API_VERSION_MAJOR 1
#define SUPPORT_VHM_API_VERSION_MINOR 0
@@ -317,6 +314,22 @@ vm_get_memflags(struct vmctx *ctx)
return ctx->memflags;
}
int
vm_map_memseg_vma(struct vmctx *ctx, size_t len, vm_paddr_t gpa,
uint64_t vma, int prot)
{
struct vm_memmap memmap;
bzero(&memmap, sizeof(struct vm_memmap));
memmap.type = VM_SYSMEM;
memmap.using_vma = 1;
memmap.vma_base = vma;
memmap.len = len;
memmap.gpa = gpa;
memmap.prot = prot;
return ioctl(ctx->fd, IC_SET_MEMSEG, &memmap);
}
static int
vm_alloc_set_memseg(struct vmctx *ctx, int segid, size_t len,
vm_paddr_t gpa, int prot, char *base, char **ptr)