Commit Graph

6810 Commits

Author SHA1 Message Date
Hu Fenglin
d128923ed9 deb-pkg: Support specifying board.xml and scenario.xml
Currently, if board.xml and scenario.xml are specified,
the variable $(BOARD) and $(SCENARIO) are path, but the
parameters passed in to generate debian package should be
board and scenario name. So add a conversion function to
ensure that the function passed to the generated debian
package is board and scenario name.

Tracked-On: #6688
Signed-off-by: Hu Fenglin <fenglin.hu@intel.com>
2021-12-02 14:39:32 +08:00
Tw
fc7e26dde8 hv: fix cpuid 0x2 mismatch when launch RTVM use atom core
When CPUID executes with EAX set to 02H, the processor returns information about cache and TLB information.
This information is percpu related, and should be obtained directly from the physical cpu.

Tracked-On: #6931
Signed-off-by: Tw <wei.tan@intel.com>
2021-12-01 17:29:30 +08:00
Tw
430fc6327d dm/tools: compatible with openssl3.0
HMAC_*, MD5_* and SHA256_* are deprecated since openssl3.0, replace them with the corresponding equivalents.

Tracked-On: #6743
Signed-off-by: Tw <wei.tan@intel.com>
2021-12-01 16:29:45 +08:00
Tw
a327608fe6 hv: fix core type error when launch RTVM use atom core
When CPUID executes with EAX set to 1AH, the processor returns information about hybrid capabilities.
This information is percpu related, and should be obtained directly from the physical cpu.

Tracked-On: #6899
Signed-off-by: Wen <qian.wen@intel.com>
Signed-off-by: Tw <wei.tan@intel.com>
2021-12-01 15:37:26 +08:00
Liu Long
5c3a080c03 ACRN:MISC: Terminology for UOS/SOS in misc
Rename get_sos_wakeup_reason to get_service_vm_wakeup_reason in acrn manager.
rename set_sos_timer to set_service_vm_timer.
rename sos_pci_devs to service_vm_pci_devs.
rename gen_sos_vm to gen_service_vm.
rename sos_used_bdf to service_vm_used_bdf.
rename is-sos-vm to is-service-vm.
rename sos_mmio_range to service_vm_mmio_range.
rename sos_guest_flags to service_vm_guest_flags.
rename get_sos_vmid to get_service_vmid.
rename sos_cpu_affinity to service_vm_cpu_affinity.
rename allocation_sos_vm_node to allocation_service_vm_node.
rename cpus_for_sos to cpus_for_service_vm.
rename sos_vm_cpus to service_vm_cpus.
rename get_sos_vuart_settings to get_service_vm_vuart_settings.
rename sos_extend_all_cpus to service_vm_extend_all_cpus.
rename sos_vm_id to servier_vm_id.
rename sos_vm_index to service_vm_index.
rename sos_vm_num to service_vm_num.
re-generate the board and scenario code by the new python and xml.
delete tdf8532 kernel module in python and shell script.

Tracked-On: #6744
Signed-off-by: Liu Long <long.liu@linux.intel.com>
2021-12-01 13:27:35 +08:00
Yonghua Huang
7a0c7dcadf dm: fix memory leakage issue in acrn_parse_cpu_affinity
there is memory leakage in this function,
 where memory pointed by 'cp'.

Tracked-On: #6919
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-12-01 08:46:37 +08:00
Xiangyang Wu
fef1585959 HV: update destination shorthand during x2apic ICR emulation
Currently, in RTVM with multi vCPUs, lapic pass through is
configured, each vCPU works in x2apic mode. When one vCPU sends
IPI to all other vCPUs, writes ICR register with the value
0x00000000000c00f8, this ICR writting will trigger VM exit,
the hypervisor passes destination shorthand field 11B (All Excluding
Self) in the virtual ICR value into physical ICR value,
this IPI will be sent to each physical CPU core
in the platform according to 10.6.1 Interrupt Command Register (ICR),
Vol 3, SDM. This will cause one User VM with lapic pass through
configuration can send IPI with any vector (such as NMI or reboot
vector) to other VM, this interference may cause other VM hang.

In this patch, set "Destination Shorthand" field of the
ICR value as 00B (No Shorthand) since the emulation is done
through sending IPI to each VCPU in dmask one by one.

Tracked-On: #6908

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
2021-12-01 08:43:34 +08:00
Shiqing Gao
c5741db091 config_tools: check VM number before filling with dynamic configured VM
check VM number before filling with dynamic configured VM

Tracked-On: #6907
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2021-12-01 08:42:50 +08:00
Conghui
ee2eb2e8e3 hv: sched: fix bug when reboot vm
When a new thread is wakeup and added to runqueue, it will get the
smallest avt (svt) from runqueue to initiate its avt. But when all
threads are blocked, and removed from the runqueue, the svt is 0. The
new thread will get avt=0. avt=0 means very high priority, and can run
for a very long time until it catchup with other thread's avt in
runqueue.

To fix it, adjust the new thread's avt when there is another thread in
runqueue.

Tracked-On: #6888
Signed-off-by: Conghui <conghui.chen@intel.com>
2021-11-25 13:43:44 +08:00
Xiangyang Wu
fe061c0930 HV: life_mngr: add sync delay for WaaG lifecycle manager
The lifecycle manager in Service VM checks sync message every
5 seconds, so need add 5 seconds to sync delay for WaaG
lifecycle manager to avoid to unnecessary sync resending.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
2021-11-25 13:41:52 +08:00
Xiangyang Wu
a67b114c73 HV: life_mngr: refine platform shutdown when User VM fails to shutdown
Currently, the lifecycle manager in Service VM will issue poweroff
command to shutdown service VM when User VM fails to shutdown. The
post-launched RTVM with virtio device may hang after Service VM
shutdown.

In this patch, the lifecycle manager in Service VM will stop to
shut down service VM when User VM fails to shutdown. Users have
chance to fix User VM shutdown failure (such as forcelly shutdown
User VM or execute poweroff command in User VM), after the failure
is fixed, user can trigger S5 in service VM to shutdown platform
gracefully.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
2021-11-25 13:41:52 +08:00
Weiyi Feng
7e8f9ce72a config_tool: load default cpu affinity config by vm_name
1. load default cpu affinity config from scenario file by vm_name.

Tracked-On: #6724
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
(cherry picked from commit 0f7d0bb145c2077d65e614fd2f476c05f71103b6)
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-25 13:41:23 +08:00
Yuanyuan Zhao
a69bd56c05 dm: fix add check for malloc result
Add check for malloc result to madt pointer.

Tracked-On: #6769
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
2021-11-25 13:40:39 +08:00
Weiyi Feng
6db72de473 config_tool: validate vm_num must <= MAX_VM_NUM
validate vm_num must <= MAX_VM_NUM

Tracked-On: #6724
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-25 13:33:16 +08:00
Weiyi Feng
1c94861156 config_tools: update MAX_VM_NUM to 8 in release_2.7
update MAX_VM_NUM to 8 in release_2.7

Tracked-On: #6685
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-25 13:33:16 +08:00
Weiyi Feng
a637fa56bf config_tool: set MAX_VM_NUM value range from 1 to 8
1. set MAX_VM_NUM value range from 1 to 8.

Tracked-On: #6685
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-25 13:33:16 +08:00
Yuanyuan Zhao
a609c9799a dm: fix mevent timing issue
If a file descriptor being monitored by epoll_wait is closed
in another thread, the result is unspecified. So add all mevents
removed in other threads to delete list. And drain the list in
the dispatch mevent thread.

Tracked-On: #6877
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-11-25 13:21:18 +08:00
Victor Sun
3f78ba191e HV: fix MISRA violation of _ld_ram_xxx
Variable should not have a prefix of '_' per MISRA C standard. The patch
removes the prefix for _ld_ram_start and _ld_ram_end.

Tracked-On: #6885

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2021-11-24 16:14:57 +08:00
Victor Sun
42cbb44891 HV: correct hv_ram_size when hv is relocated
In previous commit df7ffab441
the CONFIG_HV_RAM_SIZE was removed and the hv_ram_size was calculated in
link script by following formula:
	ld_ram_size = _ld_ram_end - _ld_ram_start ;
but _ld_ram_start is a relative address in boot section whereas _ld_ram_end
is a absolute address in global, the mix operation cause hv_ram_size is
incorrect when HV binary is relocated.

The patch fix this issue by getting _ld_ram_start and _ld_ram_end respectively
and calculated at runtime.

Tracked-On: #6885

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2021-11-24 16:14:57 +08:00
Yonghua Huang
5cbe49ab65 dm: validate input of virtio_console_control_tx()
this patch validates input of virtio_console_control_tx()
 function to avoid potential progream crash with malicious
 input from guest.

Tracked-On: #6851
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-11-18 09:38:02 +08:00
Zhou, Wu
1a856f121d dm: Skip injecting _PPC and _PCT when _PSS is not constructed
This patch is to eliminate kernel error msgs:
'ACPI Error: AE_NOT_FOUND, Evaluating _PSS'

This is caused by missing of _PSS table in guest ACPI. It would
happen when pstate is not injected to the guest.

Kernel ACPI pstate driver first probes
_PPC(performance capabilites) and _PCT(performance control)
in ACPI. If they exist, then it loads the _PSS(performance state).
If _PPC/_PCT are presented while _PSS is missing, it prints
the error msg.

In acrn-dm, _PPC/_PCT are hard-coded to all vCPUs, while _PSS
are constructed with the pCPUs' pstate data. This is base on
assumption that all VMs can have pstate.

Now the pstate is given to VM only when the VM is not sharing
any CPU(and no RTVM is setup in the scenario).
When the VM doesn't have pstate, the hypercall will return px_cnt=0,
and the _PSS is not constructed. In this case, _PPC/PCT should not
be injected, too.

Tracked-On: #6848

Signed-off-by: Zhou, Wu <wu.zhou@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-11-18 08:56:23 +08:00
Helmut Buchsbaum
55249a2f43 hv: hypercall: return 0 for empty PX or CX tables
Avoid failing hypercalls by returning 0 for empty PX and CX tables on
HC_PM_GET_CPU_STATE/PMCMD_GET_PX_CNT and
HC_PM_GET_CPU_STATE/PMCMD_GET_CX_CNT.

Tracked-On: #6848

Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-11-18 08:56:23 +08:00
Weiyi Feng
c20294ba9f config_tools: filled vm to MAX_VM_NUM in vm_configurations.c
filled vm to MAX_VM_NUM in vm_configurations.c

Tracked-On: #6685
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-17 15:25:35 +08:00
Weiyi Feng
fced1f95cb config_tool: add GUEST_FLAG_STATIC_VM define in vm_configurations.c.xsl
1. add GUEST_FLAG_STATIC_VM define in vm_configurations.c.xsl.
2. add GUEST_FLAG_STATIC_VM in guest_flags.

Tracked-On: #6685
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-17 15:25:35 +08:00
Mingqiang Chi
39e5cda391 misc: use MAX_VM_NAME_LEN
replace MAX_VMNAME_LEN with MAX_VM_NAME_LEN
to keep sync with HV and devicemodel

Tracked-On: #6685
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2021-11-17 15:25:35 +08:00
Mingqiang Chi
a87fa12895 dm: use MAX_VM_NAME_LEN instead of MAX_VMNAME_LEN
use the common MAX_VM_NAME_LEN to keep sync with hypervisor.

Tracked-On: #6685
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2021-11-17 15:25:35 +08:00
Mingqiang Chi
b864cef228 hv: port UUID update to release_v2.7
-- refine get_vmid_by_name, return the first matching vm_id
-- the GUEST_FLAG_STATIC_VM is added to identify the static or
   dynamic VM, the offline tool will set this flag for
   all the pre-defined VMs.
-- only clear name field for dynamic VM instead of clear entire
       vm_config
--  only set DM owned guest_flags in hcall_create_vm
-- add check dynamic flag in get_unused_vmid

Tracked-On: #6685
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2021-11-17 15:25:35 +08:00
Kunhui-Li
7be5cdb57b misc: remove HV_RAM_SIZE
remove HV_RAM_SIZE under misc directory because PR 6664 has
changed it in HV side.

Tracked-On: #6663
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-11-17 08:58:50 +08:00
Kunhui-Li
91bc164670 config_tools: update files under generic_code directory
update files under generic_code directory with the latest code.

Tracked-On: #6663
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-11-17 08:58:50 +08:00
Victor Sun
ba7de92c9f HV: fix build issue on RELEASE version
The HV will be built failed with below compiler message:

  common/efi_mmap.c: In function ‘init_efi_mmap_entries’:
  common/efi_mmap.c:41:11: error: unused variable ‘efi_memdesc_nr’
			[-Werror=unused-variable]
  uint32_t efi_memdesc_nr = uefi_info->memmap_size / uefi_info->memdesc_size;
  ^~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

The root cause is ASSERT() api is for DEBUG only so efi_memdesc_nr is not used
in RELEASE code.

The patch fix this issue by removing efi_memdesc_nr declaration;

Tracked-On: #6834

Signed-off-by: Victor Sun <victor.sun@intel.com>
2021-11-17 08:56:36 +08:00
Kunhui-Li
837e51acd2 config_tools: remove GUEST_FLAG_SECURITY_VM in DM_OWNED_GUEST_FLAG_MASK
GUEST_FLAG_SECURITY_VM only for pre-launch vm, should not be
programmed by device model, so we remove it in DM_OWNED_GUEST_FLAG_MASK.

Tracked-On: #6366
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-11-16 19:03:21 +08:00
Yonghua Huang
c7fa938feb dm: remove vm_get_config() API
GET_PLATFORM_INFO interface is not supported from
  hypervisor any more, remove this wrapper API in DM.

Tracked-On: #6724
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-11-15 16:02:40 +08:00
Yonghua Huang
f3e8d4e019 dm: refine logic to build ACPI table of Post-launched VM
- GET_PLATFORM_INFO will not be supported in ACRN.
  - This patch removes the dependency on this interface
    to build virtual ACPI table of post-launched VM:
      Instead of calling 'vm_get_config()' to get local
      APIC IDs, virtual ACPI builder calls new wrapper API
      'lapcid_from_pcpuid()'.

Tracked-On: #6724
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-11-15 16:02:40 +08:00
Yonghua Huang
146059c4d1 dm: refine logic to build vRTCT ACPI table
- GET_PLATFORM_INFO ioctl will not be supported by ACRN.
 - This patch removes the dependency on above interface in
   vRTCT ACPI table building:
    1) Get cache hierarchy information (threads sharing shift)
       through 'cpuid' instruction (leaf 0x04) instead of
       call vm_get_config() API.
    2) Get local APIC IDs of guest VM CPUs through new wrapper
       API 'plapicid_from_pcpuid()'.

Tracked-On: #6724
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-11-15 16:02:40 +08:00
Yuanyuan Zhao
4ad206ea5e dm: get lapic id from madt
GET_PLATFORM_INFO interface will be removed from ACRN hypervisor,
Service VM /ACRN-DM and other userland applications shall not use it any more.
For dm the lapic id was get from acrn_platform_info.
So in version 2.7, SOS madt table is parsed to get the lapic id for each pcpu.

There has an assumption. The SOS owned pcpu starts from physical cpu 0,
otherwise SOS doesn't know the mapping relationship between its vcpu0
and pcpu_id.

Tracked-On: #6724
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-11-15 16:02:40 +08:00
Yonghua Huang
9e8c1a1508 hv: reset CAT Capacity Bitmask(CBM) MSRs
ACRN get messy default values for some CAT CBM MSRs,
  these unexpected default value will result in TCC
  Software SRAM initializes crash.

  This patch resets above error default values before calling
  CRL(cache reserve library) ABI initializaion function.

Tracked-On: #6780
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-11-12 16:25:35 +08:00
Yang,Yu-chu
828edb2067 config-tools: refine acrn:get-common-clos-max
Rename function name to get-common-clos-count and refine the
calculation. Some platforms have odd clos counts. Using "floor" to get
integer numbers for macros.

Tracked-On: #6755
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-11-11 16:15:57 +08:00
Xiangyang Wu
9414d673d6 misc: life_mngr: fix some typo issues
Change macro name:
SCECOND_TO_US --> SECOND_TO_US

Use macro CONF_DIR in Makefile

Tracked-On: #6652
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
2021-11-11 13:48:01 +08:00
Shiqing Gao
0abb809ed1 hv: initialize and save/restore IA32_TSC_AUX MSR for guest
Commit cbf3825 "hv: Pass-through IA32_TSC_AUX MSR to L1 guest"
lets guest own the physical MSR IA32_TSC_AUX and does not handle this MSR
in the hypervisor.
If multiple vCPUs share the same pCPU, when one vCPU reads MSR IA32_TSC_AUX,
it may get the value set by other vCPUs.

To fix this issue, this patch does:
 - initialize the MSR content to 0 for the given vCPU, which is consistent with
   the value specified in SDM Vol3 "Table 9-1. IA-32 and Intel 64 Processor
   States Following Power-up, Reset, or INIT"
 - save/restore the MSR content for the given vCPU during context switch

v1 -> v2:
 * According to Table 9-1, the content of IA32_TSC_AUX MSR is unchanged
   following INIT, v2 updates the initialization logic so that the content for
   vCPU is consistent with SDM.

Tracked-On: #6799
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-11-11 13:20:37 +08:00
Weiyi Feng
5a18c69419 config_tool: add cpu affinity check
1. ensure cpu affinity in launch xml is subset of its scenario settings.
2. cpu_affinity is a must have parameter for acrn_dm, if the user did not provide cpu affinity in launch xml, load it from scenario settings.

Tracked-On: #6724
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-11-10 19:20:14 +08:00
Kunhui-Li
97c79fd598 config_tools: fix the duplicate PT_SLOT value issue in UI
when we add two or more virtio block devices and rename them for a VM
in launch xml files, then generate launch scripts through the UI.
After ensuring the devices names are different, we repeat these operations
continuously. Finally we will get the duplicate PT_SLOT value for
different virtio block devices in a launch script. This is wrong.

After user click the "Generate Launch Script" button to generate the
launch scripts every time, we will reset PT_SLOT variate to fix the issue.

Tracked-On: #6767

Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-11-10 19:18:09 +08:00
Xiangyang Wu
d7190ce657 deb-pkg: update deb configuration to install serial.conf
When some communication vuarts are configured in hypervisor
scenario files, serial.conf will be generated and should be
installed in the etc folder of service VM.

In this patch, update deb configuration file to install
serial.conf into etc folder of service VM.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
2021-11-10 19:16:33 +08:00
Xiangyang Wu
2c4df6de8c misc: life_mngr: add script to do user VM shutdown
COM2 in user VM is used by acrnctl to do user VM
shutdown.
In this patch series, COM2 in user VM is used as uart
channel device for new lifecycle manager. So acrnctl
can't be used to do user VM shutdown.

This patch provides a script to user to do guest
shutdown in service VM. Lifecycle manager in service
VM will send user VM shutdown command to user VM directly.

TODO: When user VM shutdown is supported in libvirt, this
script will be removed.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
a057e89781 misc: life_mngr: update Makefile for lifecycle manager
The old lifecycle manager will not be used and remove it,
update Makefile to build and install new lifecycle manager.

v1-->v2:
	Copy s5_trigger_win.py into build directory;
	Add compiler parameter (-lwsock32) to build
	life_mngr_win.c.
v3-->v4:
	Update Makefile for s5_trigger_linux.py
v4-->v5:
	Inlcude paths.make at the top-level folder.
	Generate life_mngr.service according to bindir
	variable.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
b82cfb060f misc: life_mngr: refine lifecycle manager for windows VM
Refine lifecycle manager for windows VM since new commands
are introduced in the lifecycle manager.

v1-->v2:
	Implement socket service to receive system shutdown
	request command through local host socket.
	Add one python script to trigger system shutdown
	request in windows VM.
v2-->v3:
	Update log message.
v3-->v4:
	Support guest shutdown.
v4-->v5:
	Update command name.
v5-->v7:
	Add resend message logic.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
3de9728432 misc: life_mngr: refine script to trigger system shutdown request
Provide a script to user to trigger system shutdown request
in service VM or user VM.
System shutdown logic have been integrated in the lifecycle
manager, only need to send system shutdown request command
through unix domain socket in this script.

v3-->v4:
	Rewirte system shutdown trigger script using python
	since phython script have better portability.
v4-->v5:
	Update command name and copyright header.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
070896dd76 misc: life_mngr: add monitor module
In the monitor module, the following functions are implemented:
-Implement main function of lifecycle manager, it will initialize
other module through invoking related interfaces, wait threads in
the uart module exit.

Todo:
	Will refine the name of
	init_socket_server_and_shutdown_commands,
	init_uart_channel_devs_and_shutdown_commands.

v1-->v2:
	Add comments in c file.
v2-->v3:
	Update some log message.
v3-->v6:
	Update monitior module for modulization.
v6-->v7:
	Regiester command handler for ACK receiving timeout case
	in user VM.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
4c75e43426 misc: life_mngr: add log module
In the log module, the following functions are implemented:
- open_log
Provide one interface to open log file;

-close_log
Provide one interface to close log file;

- LOG_PRINTF LOG_WRITE
Provide interfaces to write log message to log file.

v1-->v3:
	Add timestamp in the log message.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
aa31587857 misc: life_mngr: add config module
In the config module, the following functions are implemented:
- load_config
Provide one interface to load lifecycle manager configuration
from config file (life_mngr.conf), in the config file, user
can specify the VM type of VM which lifecycle manager will run
in, the VM name, the communication device name, and
the device name in service VM which is used to communicate with
the VM which is allowed to send system shutdown request.
- check_dir
Check folder exist or not, if not, create the folder
- get_allow_s5_config
Get the name of the device which is allowed to trigger
system shutdown.

v1-->v2:
	Add comments in head file.
v2-->v3:
	Update some log message.
v3-->v6:
	Simply configuration item parsing logic.
	Add get_allow_s5_config interface.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00
Xiangyang Wu
ed3a110f5f misc: life_mngr: add command handler module
In this module, the following functions are implemented:
For uart channel of service VM, implement handlers for sync command,
system shutdown request command, acked  poweroff command, vm poweroff
timeout command.
The uart channel commands of service VM and related actions are
described below:
Command			Actions
---------------------------------------------------------------
sync			Send acked sync
			command to uart in user VM
----------------------------------------------------------------
system shutdown		If this request is valid, send
request			poweroff command to each
			connected user VM through uart,
			Enable message reseding.
----------------------------------------------------------------
acked poweroff		Remove uart of user VM from
command			connection list, stop message polling,
			if connection list is empty, will
			wait for user VM status through check
			ACRN DM process instance, if all user
			VMs are	shutdown, then shutdown
			service VM
---------------------------------------------------------
ACK timeout		If it is timeout of receiving poweroff ACK,
			the action is similar to acked poweroff.
			Ohterwise, just disable message reseding.
---------------------------------------------------------

For uart channel of user VM, implement handlers for acked sync
command, poweroff command, acked system shutdown request command,
ACK timeout command.
The uart channel commands of user VM and related actions are
described below:
Command			Actions
--------------------------------------------------------
acked sync		Print log message
--------------------------------------------------------
poweroff		Disconnect uart channel,
			exit message polling, close
			unix domain socket, shutdown user VM
--------------------------------------------------------
user VM shutdown	Exit message polling, close
			unix domain socket, shutdown user VM
--------------------------------------------------------
acked system		Print log message
shutdown request
-------------------------------------------------------
ACK timeout		Disconnect uart channel,
			exit message polling, close
			unix domain socket
---------------------------------------------------------

For socket server in each VM, implement handler for system
shutdown request.
In user VM, forward this command to service VM through uart.
In service VM, send poweroff command to each connected user VM
through uart.

Implement handler for user VM shutdown request in socket server of
service VM, send user VM shutdown command to user VM which is
specified in the user VM shutdown request message.

v1-->v2:
	Add comments in c file and head file.
v2-->v3:
	Update commit message about allow s5 command and update
	some log message.
v3-->v4:
	Guest shutdown support.
v4-->v5:
	Update command name.
v5-->v6:
	Move uart channel operations into uart channel module.
v6-->v7:
	Set resend requirement for some commands.
	Add ACK receiving timeout handler for user VM.
v7-->v8:
	Update message reseding enable, this interface will be
	called before sending message.
v8-->v9:
	Use strlen to calculate the length of string, this will be
	the parameter of send_message_by_uart.

Tracked-On: #6652

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: fei1.li@intel.com
2021-11-10 18:46:15 +08:00