hv: replace MEM_2K with a new macro MAX_BOOTARGS_SIZE for bootargs size

- for all cases of referring guest bootargs size, replace MEM_2K with
  CONFIG_MAX_BOOTARGS_SIZE for better readability.
- remove duplicated MAX_BOOTARGS_SIZE definition from vm_config.h.

Also fix one minor issue in general_sw_loader() which uses copy_to_gpa()
to copy a string. Since copy_to_gpa() makes use of memncpy_s() to do the
job, the size parameter should include the string null ternimator.

Tracked-On: #2806
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Zide Chen
2019-03-19 08:42:36 -07:00
committed by wenlingz
parent 12d977284a
commit 370998ba5a
5 changed files with 22 additions and 15 deletions

View File

@@ -10,6 +10,7 @@
#include <boot_context.h>
#include <ept.h>
#include <mmu.h>
#include <multiboot.h>
#include <errno.h>
#include <sprintf.h>
#include <logmsg.h>
@@ -146,7 +147,7 @@ int32_t general_sw_loader(struct acrn_vm *vm)
/* Copy Guest OS bootargs to its load location */
(void)copy_to_gpa(vm, linux_info->bootargs_src_addr,
(uint64_t)linux_info->bootargs_load_addr,
(strnlen_s((char *)linux_info->bootargs_src_addr, MEM_2K - 1U) + 1U));
(strnlen_s((char *)linux_info->bootargs_src_addr, MAX_BOOTARGS_SIZE) + 1U));
/* add "hugepagesz=1G hugepages=x" to cmdline for 1G hugepage
* reserving. Current strategy is "total_mem_size in Giga -