mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 04:02:05 +00:00
vm load: add SOS cmdline option for hugetlb
adding "hugepagesz=1G" and "hugepages=X" into SOS cmdline, for X, current strategy is making it equal e820_mem.total_mem_size -CONFIG_REMAIN_1G_PAGES if CONFIG_REMAIN_1G_PAGES is not set, it will use 3 by default. CONFIG_CMA is added to indicate using cma cmdline option for SOS kernel, by default system will use hugetlb cmdline option if no CONFIG_CMA defined. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Xu, Anthony <anthony.xu@intel.com>
This commit is contained in:
parent
a1145b0b55
commit
76091d0d01
@ -196,6 +196,7 @@ void obtain_e820_mem_info(void)
|
|||||||
|
|
||||||
e820_mem.mem_bottom = UINT64_MAX;
|
e820_mem.mem_bottom = UINT64_MAX;
|
||||||
e820_mem.mem_top = 0x00;
|
e820_mem.mem_top = 0x00;
|
||||||
|
e820_mem.total_mem_size = 0;
|
||||||
e820_mem.max_ram_blk_base = 0;
|
e820_mem.max_ram_blk_base = 0;
|
||||||
e820_mem.max_ram_blk_size = 0;
|
e820_mem.max_ram_blk_size = 0;
|
||||||
|
|
||||||
@ -210,11 +211,13 @@ void obtain_e820_mem_info(void)
|
|||||||
+ entry->length;
|
+ entry->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->baseaddr == UOS_DEFAULT_START_ADDR
|
if (entry->type == E820_TYPE_RAM) {
|
||||||
&& entry->type == E820_TYPE_RAM) {
|
e820_mem.total_mem_size += entry->length;
|
||||||
e820_mem.max_ram_blk_base =
|
if (entry->baseaddr == UOS_DEFAULT_START_ADDR) {
|
||||||
entry->baseaddr;
|
e820_mem.max_ram_blk_base =
|
||||||
e820_mem.max_ram_blk_size = entry->length;
|
entry->baseaddr;
|
||||||
|
e820_mem.max_ram_blk_size = entry->length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +285,9 @@ static void rebuild_vm0_e820(void)
|
|||||||
entry->type = new_entry.type;
|
entry->type = new_entry.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e820_mem.total_mem_size -= CONFIG_RAM_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prepare_vm0_memmap_and_e820(struct vm *vm)
|
int prepare_vm0_memmap_and_e820(struct vm *vm)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -45,4 +45,5 @@
|
|||||||
#define CONFIG_LOW_RAM_SIZE 0x000CF000
|
#define CONFIG_LOW_RAM_SIZE 0x000CF000
|
||||||
#define CONFIG_RAM_START 0x6E000000
|
#define CONFIG_RAM_START 0x6E000000
|
||||||
#define CONFIG_RAM_SIZE 0x02000000 /* 32M */
|
#define CONFIG_RAM_SIZE 0x02000000 /* 32M */
|
||||||
|
#define CONFIG_CMA
|
||||||
#endif /* BSP_CFG_H */
|
#endif /* BSP_CFG_H */
|
||||||
|
@ -187,6 +187,7 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
|||||||
strcpy_s((char *)hva, MEM_2K,
|
strcpy_s((char *)hva, MEM_2K,
|
||||||
vm->sw.linux_info.bootargs_src_addr);
|
vm->sw.linux_info.bootargs_src_addr);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CMA
|
||||||
/* add "cma=XXXXM@0xXXXXXXXX" to cmdline*/
|
/* add "cma=XXXXM@0xXXXXXXXX" to cmdline*/
|
||||||
if (is_vm0(vm) && (e820_mem.max_ram_blk_size > 0)) {
|
if (is_vm0(vm) && (e820_mem.max_ram_blk_size > 0)) {
|
||||||
snprintf(dyn_bootargs, 100, " cma=%dM@0x%llx\n",
|
snprintf(dyn_bootargs, 100, " cma=%dM@0x%llx\n",
|
||||||
@ -197,6 +198,32 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
|
|||||||
+vm->sw.linux_info.bootargs_size - 1,
|
+vm->sw.linux_info.bootargs_size - 1,
|
||||||
100, dyn_bootargs);
|
100, dyn_bootargs);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* add "hugepagesz=1G hugepages=x" to cmdline for 1G hugepage
|
||||||
|
* reserving. Current strategy is "total_mem_size in Giga -
|
||||||
|
* remained 1G pages" for reserving.
|
||||||
|
*/
|
||||||
|
if (is_vm0(vm) && check_mmu_1gb_support(PTT_HOST)) {
|
||||||
|
int reserving_1g_pages;
|
||||||
|
|
||||||
|
#ifdef CONFIG_REMAIN_1G_PAGES
|
||||||
|
reserving_1g_pages = (e820_mem.total_mem_size >> 30) -
|
||||||
|
CONFIG_REMAIN_1G_PAGES;
|
||||||
|
#else
|
||||||
|
reserving_1g_pages = (e820_mem.total_mem_size >> 30) -
|
||||||
|
3;
|
||||||
|
#endif
|
||||||
|
if (reserving_1g_pages > 0) {
|
||||||
|
snprintf(dyn_bootargs, 100,
|
||||||
|
" hugepagesz=1G hugepages=%d\n",
|
||||||
|
reserving_1g_pages);
|
||||||
|
/* Delete '\n' at the end of cmdline */
|
||||||
|
strcpy_s((char *)hva
|
||||||
|
+vm->sw.linux_info.bootargs_size - 1,
|
||||||
|
100, dyn_bootargs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check if a RAM disk is present with Linux guest */
|
/* Check if a RAM disk is present with Linux guest */
|
||||||
if (vm->sw.linux_info.ramdisk_src_addr) {
|
if (vm->sw.linux_info.ramdisk_src_addr) {
|
||||||
|
@ -62,6 +62,7 @@ struct vhm_request;
|
|||||||
struct e820_mem_params {
|
struct e820_mem_params {
|
||||||
uint64_t mem_bottom;
|
uint64_t mem_bottom;
|
||||||
uint64_t mem_top;
|
uint64_t mem_top;
|
||||||
|
uint64_t total_mem_size;
|
||||||
uint64_t max_ram_blk_base; /* used for the start address of UOS */
|
uint64_t max_ram_blk_base; /* used for the start address of UOS */
|
||||||
uint64_t max_ram_blk_size;
|
uint64_t max_ram_blk_size;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user