Commit Graph

29 Commits

Author SHA1 Message Date
Ziheng Li eb8bcb06b3 Update copyright year range in code headers
Modified the copyright year range in code, and corrected "int32_tel"
into "Intel" in two "hypervisor/include/debug/profiling.h" and
"hypervisor/include/debug/profiling_internal.h".

Tracked-On: #7559
Signed-off-by: Ziheng Li <ziheng.li@intel.com>
2022-07-15 11:48:35 +08:00
Geoffroy Van Cutsem 8b16be9185 Remove "All rights reserved" string headers
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).

Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-04-06 13:21:02 +08:00
Liu Long 3f4ea38158 ACRN: misc: Unify terminology for service vm/user vm
Rename SOS_VM type to SERVICE_VM
rename UOS to User VM in XML description
rename uos_thread_pid to user_vm_thread_pid
rename devname_uos to devname_user_vm
rename uosid to user_vmid
rename UOS_ACK to USER_VM_ACK
rename SOS_VM_CONFIG_CPU_AFFINITY to SERVICE_VM_CONFIG_CPU_AFFINITY
rename SOS_COM to SERVICE_VM_COM
rename SOS_UART1_VALID_NUM" to SERVICE_VM_UART1_VALID_NUM
rename SOS_BOOTARGS_DIFF to SERVICE_VM_BOOTARGS_DIFF
rename uos to user_vm in launch script and xml

Tracked-On: #6744
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2021-11-02 10:00:55 +08:00
Yifan Liu 4252bc247d misc: efi-stub: Set MOR bit before jumping to hypervisor
This patch sets the MemoryOverwriteRequestControl (MORCtrl for short)
EFI variable before jumping to hypervisor.

Setting variable MemoryOverwriteRequestControlLock (MORCtrlLock for
short) can also be enabled by manually adding -DMORCTRL_LOCK_ENABLED to
CFLAGS.

Setting MORCtrl indicates to the platform firmware that memory be
cleared upon system reset. Setting MORCtrlLock for the first time will
render both MORCtrl and MORCtrlLock to read-only, until next reset.

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu c2217aa5d4 misc: efi-stub: Implement modules loading in container
This patch implements the container_load_modules function.
This function loads multiboot modules following multiboot protocol.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu e0f69399ff misc: efi-stub: Implement boot image loading in container
This patch implements the container_load_boot_image function.
This function loads boot image following multiboot protocol.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu daa42752d2 misc: efi-stub: Add barebone container as an implementation of HV_LOADER
Previous patches introduces an abstract struct HV_LOADER to do two
things: load boot image and load boot modules. This patch provides an
implementation barebone of container. The implementation of critical
functions container_load_boot_image and container_load_modules will come
in coming patches.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu e32640aab6 misc: efi-stub: Add helper functions to parse/load ELF32 image
This patch adds a file containing some helper functions to load
or validate ELF32 images.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu 6cb667f137 misc: efi-stub: Add helper functions to search/parse multiboot1/2 headers
This patch adds a file containing some helper functions to search or parse
multiboot headers.

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu 8c45359170 misc: efi-stub: Prepare multiboot1 info for HV
This patch adds code to prepare multiboot1 info passed to hypervisor.

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu f3d1823754 misc: efi-stub: Prepare multiboot2 info for HV
This patch adds code to prepare multiboot2 info passed to hypervisor.
Currently we prepare only the following information to hypervisor:
    Boot command line
    Boot loader name
    Modules
    Memory Map
    ACPI table
    EFI64 system table
    EFI memory map

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu 52790b5c0e misc: efi-stub: Barebone efi-stub for secure boot
ACRN EFI application based on the legacy efi-stub code provides booting method
of HV on UEFI-BIOS without using the GRUB Bootloader. It is supposed to be used
for secure booting on certain platform. By means of that users can boot HV,
Service VM kernel, pre-launched VM kernel and its ACPI table binary packed in
the Slim Bootloader container boot image file format. ACRN EFI application has
additional dependencies to compile which are not listed in the existing ACRN GSG
doc. Since this is an optional feature but not all users need, it does not get
compiled by default to avoid causing any confusion for existing users. README
for how to use the feature will come later in a separated commit.

This patch adds barebone implementation of this efi-stub. The following
files are reused from a previous version of efi-stub without changes:
    efilinux.h, pe.c, stdlib.h

Other files contains stubbed functions, whose implementation will come
in coming patches.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Co-developed-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Zide Chen 472534e922 efi-stub: remove efi-stub
UEFI boot is no longer supported in ACRN.

Tracked-On: #5197
Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-10-21 15:09:26 +08:00
Minggui Cao a335679ce9 Makefile: remove 'clean' when building HV/DM
1. not need 'clean' when building ACRN-HV/DM each time
2. correct efi-stub wrong dependency

Tracked-On: #2412
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2020-05-21 15:12:21 +08:00
Zide Chen 1bc5c7ac5b hv/acrn-config/efi-stuf: assign hvlog and ramoops buffer address < 256MB
If HV relocation is enabled, either ACRN efi-stub or GRUB relocates
hypervisor image above HPA 256MB, thus we put hvlog and ramoops buffer
under 256MB to avoid conflict with hypervisor owned address.

This patch hardcodes these addresses:

0xa00000 - 0xdfffff: 4MiB for ramoops buffer
0xe00000 - 0xffffff: 2MiB for hvlog buffer

However, user can customize them to other addresses as long as it's under
256MB, available in host e820, and SOS bootarg "nokaslr" is not specified.

If HV relocation is disabled, need to make sure that these buffer
addresses are not between HV_RAM_START and HV_RAM_START + HV_RAM_SIZE.

Tracked-On: #4760
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2020-05-13 08:36:54 +08:00
Zide Chen be4797a10c efi-stub: don't relocate hypervisor to address lower than 256MB
With this patch, we relocate hypervisor image to HPA 256MB and above,
thus the hardcoded hvlog and ramoops buffer for SOS can safely reside at
addresses under HPA 256MB, given that 1:1 mapping between SOS GPA and HPA.

Tracked-On: #4760
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2020-05-13 08:36:54 +08:00
Yin Fengwei c9e3d36ef1 efi-stub: fix wrong bootloader name issue
UEFI pass option as unicode string to efi-stub. That string has
no end charactor ('\0'). Insteadly, the option has string size
and we should use the string size to decide the end of the option
string.

Tracked-On: #4520
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
2020-03-25 14:37:00 +08:00
Zide Chen 67cb1029d9 hv: update the hypervisor 64-bit entry address for efi-stub
- remove .data and .text directives. We want to place all the boot data and
  text in the .entry section since the boot code is different from others
  in terms of relocation fixup. With this change, the page tables are in
  entry section now and it's aligned at 4KB.

- regardless CONFIG_MULTIBOOT2 is set or not, the 64-bit entry offset is
  fixed at 0x1200:

  0x00 -- 0x10: Multiboot1 header
  0x10 -- 0x88: Multiboot2 header if CONFIG_MULTIBOOT2 is set
  0x1000: start of entry section: cpu_primary_start_32
  0x1200: cpu_primary_start_64 (thanks to the '.org 0x200' directive)
          GDT tables
	  initial page tables
	  etc.

Tracked-On: #4441
Reviewed-by: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-03-06 08:27:46 +08:00
Conghui Chen 557e7f19f7 Makefile: add gcc flags to prevent some optimization
Add the below flags, they are needed in -O2:

-fno-delete-null-pointer-checks:
    * tells the compiler NOT to assume that null pointer deference does
    not exist.

    * Without this flag, below case cannot be detected:
    a pointer might point to nullsometime during run-time and if there
    is no validation for that pointer, it will cause the program to crash.
    Since we don’t receive an error message saying that a pointer is
    pointing to null, we will have a hard time trying to find the problem.

-fwrapv:
    * tells the compiler that signed overflow always wraps.

    * Without this flag, x + 10 > x will always be true for signed x.
     With the flag, x + 10 > x is not always be true, as the overflow is
     defined for x, and it could wrap.

Tracked-On: #4194
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-12-10 10:02:15 +08:00
Geoffroy Van Cutsem 51a43dab79 hv: add Kconfig parameter to define the Service VM EFI bootloader
Add a Kconfig parameter called UEFI_OS_LOADER_NAME to hold the Service VM EFI
bootloader to be run by the ACRN hypervisor. A new string manipulation function
to convert from (char *) to (CHAR16 *) has been added to facilitate the
implementation.

The default value is set to systemd-boot (bootloaderx64.efi)

Tracked-On: #2793
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-11-27 10:38:49 +08:00
Victor Sun 0011607a16 Makefile: refine include path for efi_stub
Move hypervisor related include path from CFLAGS to INCLUDE_PATH to make
structure more clean.

Tracked-On: #3779

Signed-off-by: Victor Sun <victor.sun@intel.com>
2019-11-12 10:51:04 +08:00
Li Fei1 af886fee8c efi-stub: reserve unconfigure high memory
Now ACRN support more and more platforms. However, the default configuration only
support board which memory is less than 16 GB. If a board memory is large than
16 GB, the developer needs to configure the memory configuration according to his
board. Otherwise, the boot will fail. This's because UEFI BIOS will use the high
memory as possible.
This patch try to allocate the memory as eraly as possible. So that the BIOS will
not access this region.

Tracked-On: #4007
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2019-11-07 08:47:02 +08:00
wenlingz c8fa8e15f8 Modify KBL-NUC/SDC for default build
Tracked-On: #3968
Signed-off-by: wenlingz <wenling.zhang@intel.com>
2019-11-01 09:06:45 +08:00
Victor Sun 0906b25ca2 Makefile: build default acrn.efi with nuc6cayh
To be back compatible, the default acrn.efi should be built when
BOARD param is nuc6cayh, because apl-nuc was overridden to nuc6cayh
in acrn-hypervisor/Makefile;

Tracked-On: #3602

Signed-off-by: Victor Sun <victor.sun@intel.com>
2019-09-29 15:09:38 +08:00
Victor Sun 0b65b8f05c Makefile: override .config with specified scenario
1. if SCENARIO=$(SCENARIO) is specified in make param, then override
the default CONFIG_$(SCENARIO) value in existed .config. This means
we don't need to modify the default SCENARIO config in Kconfig file
to build the hypervisor;

2. Some board name shortcuts like apl-nuc/kbl-nuc-i7 need to be converted
to official board name to make sure overrides working;

3. Previously make sbl-hypervisor did not load the defconfig so the
defconfig for boards are lost, this patch fix this issue;

4. remove SCENARIO param when make hypervisor, because SCENARIO could
be got from SCENARIO_NAME which parsed from .config;

Tracked-On: #3593

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-09-18 11:48:31 +08:00
Tw 1547a4cb27 efi-stub: fix stack memory free issue
Because of this commit:

    commit 63e258bd01
    Author: Tianhua Sun <tianhuax.s.sun@intel.com>
    Date:   Wed Jul 17 14:33:47 2019 +0800

	efi-stub: update string operation in efi-stub

	Remove unsafe API in efi-stub
	1, use Strnlen instead of StrLen except the parameter
	   is a static string.
	2, strlen() only work on static strings.

	Tracked-On: #3276
	Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
	Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>

In the default case, bootloader_name will be point to a separate ro
section which hold the constant string, free this memory later will
cause undefined behavior (memory corruption, exception and so on).

Tracked-On: #3644
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Jack Ren <jack.ren@intel.com>
2019-09-05 16:32:06 +08:00
Yin Fengwei adf3a59302 Makefile: Refine Makefile to generate both industry and sdc images
We are trying to add both industry and sdc images to CL build. To
maintain the build interface unchanged (no change from CL side), we
extend the build command to generate the different target images.

To identity different images, we use rule:
   $(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO)
as target image file name.

Tracked-On: #3593
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-09-02 19:25:31 +08:00
fuyanX 83e887dbb3 memmap:reserve phys-addr for hvlog
acrn.conf:add memmap phys-addr 2M for hvlog,
not mapped by kernel.

Tracked-On: projectacrn/acrn-hypervisor#3533
Signed-off-by: YanX Fu <yanx.fu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-08-05 18:27:38 +08:00
Terry Zou a9c38a5cfb HV:Acrn-hypvervisor Root Directory Clean-up and create misc/ folder for Acrn daemons, services and tools.
This patch is to clean-up acrn-hypervisor root directory, targt only 5 folders under acrn-hypervisor:1.hypervisor,2.devicemodel,3.misc,4.doc,5.build

Tracked-On: #3482
Signed-off-by: Terry Zou <terry.zou@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-29 22:58:24 +08:00