Commit Graph

2428 Commits

Author SHA1 Message Date
Shiqing Gao 8920fbacaa hv: clean up function definitions in logmsg.h
seperate the function definitions into debug/release directories
to better distinguish debug/release libraries

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-28 14:57:49 +08:00
Huihuang Shi 5b6c611a1d hv: msix: fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule.

Reduce the count of the "return entries".
Fix the violations which is comply with the cases list below:
1.Function has 2 return entries.
2.The first return entry is used to return the error code of
checking variable whether is valid.

V1->V2:
  remove the unrelated code.

Fix the violations in "if else" format.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-28 14:34:12 +08:00
yuhong.tao@intel.com 2f33d1bcf2 tools: acrn-manager: Fix acrnctl mistake displaying suspended to paused
When UOS is sleeping, 'acrnctl list' command show it is 'paused', not
'suspended'. That is not correct. Because pausing an UOS means to block
its VCPUs immediately, otherwise suspending an UOS means to put it to
sleep.

Tracked-On: #1910
Acked-by: Yan, Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-11-28 13:42:27 +08:00
Li, Fei1 e1d0f7e432 hv: instr_emul: fix decode_modrm no default case in switch statement
MISRA-C required every switch statement shall have a default label.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-28 13:25:56 +08:00
Li, Fei1 042c393526 hv: trusty: fix get_max_svn_index return type inconsistent
Function return type should consistent.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-11-28 13:25:56 +08:00
Li, Fei1 c200c98405 hv: include: remove name starts with underscore
Remove name starts with underscore for HV_CONFIG

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-11-28 13:25:56 +08:00
Chen Gang G 0100b5a2e1 HV: replace dynamic memory with static for crypto library
Remove dynamic memory allocation in crypto lib, use array to
replace them.

Tracked-On: #1900
Reviewed-by: Bing Zhu <bing.zhu@intel.com>
Signed-off-by: Chen Gang G <gang.g.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-28 10:24:57 +08:00
Huihuang Shi 2afa7173ef hv: vlapic: fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule.

Reduce the count of the "return entries".
Fix the violations which is comply with the cases list below:
1.Function has 2 return entries.
2.The first return entry is used to return the error code of
checking variable whether is valid.

Fix the violations in "if else" format.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-27 14:43:16 +08:00
Liu, Xinwu 3d1332f392 tools: acrn-crashlog: refine the log storage
1. remove watching TOMBSTONE in AaaG.
2. add a configurable parameter "foldersize" in MB, sender will drop
   all events when the storaged log size exceeds this parameter.

Tracked-On:#1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Chen Gang <gang.c.chen@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-11-27 14:26:25 +08:00
Shiqing Gao 06efc58a7e hv: assign: clean up HV_DEBUG usage related to vuart pin
replace HV_DEBUG with CONFIG_COM_IRQ which is more reasonable

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-27 13:09:24 +08:00
Mingqiang Chi c380ee9eeb hv:Revise sanitized page size
now the size of sanitized_page is 32KB,
revise it to 4KB.

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-27 13:09:04 +08:00
Kaige Fu a5fd552456 debug: rename struct logmsg to struct acrn_logmsg_ctl
For data structure types "struct logmsg", its name is identical
with variable name in the same scope. This is a MISRA C violation.

This patch fix it.

Tracked-On: #1801
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-27 09:32:27 +08:00
Kaige Fu e555f75b8d debug: Remove early logbuf support
This patch remove early logbuf support which is used to hold
log massges before shared buf setup by SOS.

Tracked-On: #1801
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
2018-11-27 09:32:27 +08:00
Huihuang Shi 9f13a51e8a hv: hypercall: VM management fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule.

Reduce the count of the "return entries".
Fix the violations which is comply with the cases list below:
1.Function has 2 return entries.
2.The first return entry is used to return the error code of
checking variable whether is valid.

Fix the violations in "if else" format.
V1->V2:
    update the git comment to describe why comply with the
single-exit rule.

V2->V3:
    update the git comment title to give a scope declaration of this
patch.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-27 09:27:00 +08:00
Huihuang Shi a7398e8a2f hv: hypercall: general fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule.

Reduce the count of the "return entries".
Fix the violations which is comply with the cases list below:
1.Function has 2 return entries.
2.The first return entry is used to return the error code of
checking variable whether is valid.

Fix the violations in "if else" format.
V1->V2:
    update the git comment to describe why comply with the
rule(function's return entry should be only one).
V2->V3:
    update the git comment title to give a scope declaration of this
patch.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-27 09:27:00 +08:00
Zide Chen b627c2c979 hv: switch IA32_TSC_AUX between host/guest through VM Controls
Currently guest IA32_TSC_AUX MSR is loaded manually right before VM
entry, and saved right after VM exit.

This patch enables VM-Entry Control and VM-Exit Control to switch
MSR IA32_TSC_AUX between host and guest automatically. This helps to
keep vcpu_thread() function and struct acrn_vcpu cleaner.

Also it removes the dead code of intercepting IA32_TSC_AUX.

Tracked-On: #1867
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-27 09:26:29 +08:00
Li, Fei1 d0b37f8ea2 hv: reloc: define data structure and MACRO when necessary
Some data structure are only used under some condition. This patch move data
structure definition under its corresponding contion. Otherwise, it would
violate MISRA-C 413 S "User type declared but not used in code analysed".
For MACRO, it would violate MISRA-C 628 S "Macro not used in translation unit".

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-26 12:42:03 +08:00
Yuan Liu d043171de5 IOC mediator: Add VehicalSteeringWheelAngle signal to the whitelist
The signal is used to get camera right and left values.

Tracked-On: #1886
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-23 14:59:07 +08:00
Tomas Winkler 580579a392 dm: mei: Use compare and swap primitive for refcnt.
Simple atomic add/dec do no guarantee reference count full
synchronization without a lock. Compare and swap operations
are required for correct implementation.

Tracked-On: #1875
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-23 14:13:14 +08:00
Shiqing Gao b1047224aa hv: assign: clean up HV_DEBUG usage related to shell
remove the usage of HV_DEBUG related to shell command in assign.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-23 12:21:02 +08:00
Shiqing Gao f21e36f43b hv: vioapic: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in vioapic.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-23 12:21:02 +08:00
Shiqing Gao a931229888 hv: irq: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in irq.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-23 12:21:02 +08:00
Shiqing Gao dfe48811d4 hv: vcpu: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in vcpu.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-23 12:21:02 +08:00
Shiqing Gao e49929a776 hv: ioapic: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in ioapic.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-23 12:21:02 +08:00
Yonghua Huang 9d529fb9e6 hv:use copy of guest's memory block in 'hcall_set_vm_memory_regions()'
to avoid passing guest's memory block into hypervisor internal
process for security.

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-23 09:05:15 +08:00
Shiqing Gao 81db242292 hv: enhance Makefile to compile debug/release into 2 libraries
enhance Makefile to compile debug/release into 2 libraries

v1 -> v2:
 * auto make all the libraries

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2018-11-23 08:47:34 +08:00
Yin Fengwei 19b35f9730 acrn-dm: wait for monitor thread canceling finish
When thread_cancel() is called to exit pthread, we can't know
when the thread exit done unless pthread_join() is used to
wait for thread exit.

Tracked-On: #1868
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-22 12:52:12 +08:00
Li, Fei1 02a89dd473 hv: lapic: fix a theoretic infinite loop when clear lapic isr
In theory, there would have 256 pending interrupts on lapic ISR.
Add this check to avoid theoretic infinite loop for clearing
lapic isr. Leave the potentially hardware issue to machine check.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-11-22 12:44:21 +08:00
Li, Fei1 dbe3d986c0 hv: lapic: save lapic base MSR when suspend
Although the lapic base MSR have the same value in per-cpu except that the BSP bit.
However, we would enter s3 on the BSP cpu. After the resume from s3, the BSP bit was
clear on the BSP cpu. This patch fix this bug.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-22 12:44:21 +08:00
Li, Fei1 b8a553d16a hv: lapic: remove union apic_lvt
Since it's unused.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-11-22 12:44:21 +08:00
Mingqiang Chi 538ba08c2b hv:Add vpin to ptdev entry mapping for vpic/vioapic
Now if the vmexit reason is virtulized EOI for level triggered
interrupts, HV will loop all the ptdev entries, it is time-consuming,
this patch add vpin to ptdev entry mapping for vpic and vioapic
when add intx entry for a vm,it can use the ptdev entry directly
according to the mapping for vpin and ptdev entry when EOI vmexit.

v3-->v4:
  -- add check vpin in remove_intx_remapping
  -- move check vpin from ptdev_add_intx_remapping to add_intx_remapping

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2018-11-22 11:26:04 +08:00
Mingqiang Chi 297a264a74 hv:Cleanup ptdev lock
Move ptdev lock out from add_intx_remapping/add_msix_remapping
/remove_intx_remapping/remove_msix_remapping and make it protect
the whole add entry/remove entry process

v3-->v4:
  --move ptdev lock out

v2-->v3:
  -- still use ptdev lock for add/remove ptdev entry
Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2018-11-22 11:26:04 +08:00
Mingqiang Chi b7bbf81287 hv:Replace dynamic memory with static for ptdev
-- Config MAX_PT_IRQ_ENTRIES 64 in Kconfig
-- Remove ptdev list
-- Add alloc_ptdev_entry_id api

v3-->v4:
  -- move is_entry_active from assign.c to ptdev.h
  -- Add clear active flag in release_entry
v2-->v3:
  -- Remove redundancy active check for ptdev entry
     in release_all_entries and get_ptdev_info
v1-->v2:
  -- split to small patches

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2018-11-22 11:26:04 +08:00
dongshen b0e1657b4f HV: Adding partition mode support for cb2_dnv
Adding partition mode support for cb2_dnv.

Tracked-On: #1853
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-11-21 15:21:37 +08:00
dongshen 664bc1bace HV: Partition mode source code file layout reorg
Put partition mode board specific files under partition/$(CONFIG_BOARD)/

Tracked-On: #1852
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-11-21 15:21:37 +08:00
Tomas Winkler 031191dbcd dm: apl-mrb: launch_uos: remove mei debug flags
Tracked-On: #1849
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-21 15:17:05 +08:00
Alexander Usyskin 378afc5093 dm: mei: fix clients scan in sysfs
Fix the prefix comparison, we need to compare on prefix length, not
on devpath len, otherwise we always fail.

Tracked-On: #1848
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-21 15:17:05 +08:00
Alexander Usyskin 7bd2976f9c dm: mei: add zero termination to devpath
Reset directory name to receive clean prints.

Tracked-On: #1847
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-21 15:17:05 +08:00
Tomas Winkler 87fbb7003d dm: mei: fix double fw_reset on uos reboot
Edge triggered mevent on sysfs file is triggered
immediately after mevent_add(), hence this has to be ignored.
The issue that is resolved that the 'first' flag was
global and wasn't reset on each mevent_add().

Tracked-On: #1846
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-21 15:17:05 +08:00
Alexander Usyskin 844553ef23 dm: mei: check for state before link reset callback
Prevent intercepting reset callback if reset state
transition is already in progress.

Tracked-On: #1846
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-21 15:17:05 +08:00
Zide Chen 58ab26ea38 hv: code cleanup: msr.h
- fix code style: mix of tab and white spaces, alignments, etc.
- remove not meaningful comments. Also these comments are below the
  source code which makes the code look messy.
- add more MSR register definitions

Tracked-On: #1867
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-21 14:45:43 +08:00
Shuo Liu e8296dce05 hv: Add IO request completion polling feature
This patch introduce a new mode of IO request completion, polling mode.

Now, the sketch of ioreq process can be,
  A. UOS vcpu0 generate PIO/MMIO ->
   B. pcpu1(vcpu0 of UOS) trap into HV ->
    C. pcpu1 build ioreq, send IPI and enter idle ->
     D.1 pcpu0(vcpu0 of SOS) response IPI,
     D.2 pcpu0 handle the ioreq in HV, kernel, DM,
     D.3 pcpu0 mark ioreq as complete,
     D.4 pcpu0 hypercall to enter HV ->
       E.1 pcpu0 send IPI to wake pcpu1 up
       E.2 UOS vcpu0 continue running

With this change, it skips D.4, E.1 steps. In step C, pcpu1 will enter a
polling ioreq state idle after send out the IPI.
It can save about ~5000 cpu cycles.

In polling mode, we do the polling in idle instead of pause cpu all the
time. It will consume more power. A better way is to use monitor/mwait
instructions which can put cpu into a sleep state with monitoring a
memory address. Unfortunately, APL has bug with monitor. We can gather
all ioreqs state into one monitorable memory and take advantage of
monitor/mwait for future platform.

The way polling or notification is per VM. We can config VMs in
different mode. By default, IO request completion will use notification
mode for all VMs. We can switch it by Kconfig.

Tracked-On: #1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-21 14:35:12 +08:00
Minggui Cao e350abe40d HV: handle adding ptdev entry failure cases
handle adding pass-through device entry failure cases,
instead of calling ASSERT, to avoid hypervisor crash.

Tracked-On: #1860
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-21 12:40:23 +08:00
Binbin Wu fe08a44e83 hv: doc: use doxygen-generated API docs in HLD for passthru
This patch adds vtd.h to the input of doxygen and replaces hard-coded API docs
with doxygen-generated ones.

Tracked-On: #1595
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-21 09:27:51 +08:00
Binbin Wu 973c616ab3 doc: passthru: add structure and API docs
This patch adds more comments to describe the structures and functions of vtd
that are public to the other components in the hypervisor. The comments are in
doxygen-style for document generation.

Tracked-On: #1595
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-21 09:27:51 +08:00
Geoffroy Van Cutsem 4ec4ddc0cc Documentation: clean-up of isolated README.rst files
Clean up of a couple of README.rst files located respectively under hypervisor/
and devicemodel/ to remove obsolete and unmaintained information. Both hold a
basic introduction about the folder content and refer to the official
documentation website for more detailed information.

Tracked-On: #1827
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-20 11:09:53 -08:00
Binbin Wu 29f9502152 hv: vtd: error handling revisit
1. use error code defined in errno.h instead of 1.
2. panic if error occured while adding devices to VM0 domain.
3. panic if failed to reqeust irq for iommu.

The two panic added would only occurs before any VM starts running.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-20 13:30:13 +08:00
Binbin Wu c449002846 hv: vtd: defer dma remapping enabling until vm creation
In current code, DMA remapping is enabled at very early stage, when there is no
device added.
Devices are added to VT-d context table when creating VMs.
There is potential risk that there may be device DMA transactions when DMA remapping is
enabled, but the device is not added to the VT-d context table. (Eg. this could happen in UEFI
enviroment when USB keyboard use in efi intenal shell.)

This patch defers DMA remapping enabling until vm creation.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-20 13:30:13 +08:00
Binbin Wu 42e0e169c3 hv: vtd: init interrupt config when resume
Current code doesn't init interrupt config when resume from S3.
The related register contect will be lost during S3.
This patch re-init these regiters.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-20 13:30:13 +08:00
Binbin Wu 830b3aa07c hv: vtd: check vtd enabling status with spinlock
Check vtd translation enabling status when enable/disable translation
inside dmar_enable/disable_translation with spinlock.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-20 13:30:13 +08:00