Commit Graph

2141 Commits

Author SHA1 Message Date
Minggui Cao 0307b21896 HV: change vuart port (used by SOS) to ttyS2
On MRB, there are some differences for SOS uart setting between
debug version and release version:
  for debug version, ttyS0 is vuart, ttyS1 is 00:18.0, ttyS2 is 00:18.1,
    ttyS3 is 00:18.3.
  for release version, ttyS0 is 00:18.0, ttyS1 is 00:18.1, ttyS2 is
00:18.2, ttyS3 is 00:18.3. There is no vuart.

port: 00:18.0 is for bluetooth usage, ttyS0 can't be used as SOS console
for release build.

after change, debug build: vuart -->ttyS2 (SOS console);
release version: ttyS2; 00:18.2, it can be used as SOS console too.

for UEFI platform, also change acrn.conf console=ttyS0-->ttyS2
to matched with vart change.

Tracked-On: #1690
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-11-02 13:00:54 +08:00
David B. Kinder 9029ac4bd5 doc: update Tracked-on in contribute guide
All PRs must have a Tracked-on: tag

Tracked-on: #1420

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-11-01 21:18:39 -07:00
David B. Kinder a86248ecd2 doc: hide doxygen duplicate definition warnings
Sphinx/Breathe have a known problem with processing unnamed nested
structs and unions that cause a "Duplicate definition" warning.

Use our .known-issues filter to hide these in the HLD content.

Tracked-on: #1706
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-11-01 20:55:11 -07:00
Liu, Xinwu 3ffa9686ca tools: acrn-crashlog: fix potential issues
Changes include:
1. check the parameter of snprintf
2. remove atoi
3. remove sscanf
4. fix one memleak

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2018-11-02 11:52:01 +08:00
Shiqing Gao 111f9726d0 hv: fix integer violations
The operands to shift operations (<<, >>) shall be unsigned integers.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-02 11:05:32 +08:00
Yin Fengwei 4c1cb60684 hv: Remove the up_count_spinlock and use atomic for up_count
It's possible that the up_count_spinlock is not release during
system enter S3. The case is like following:

   BSP                                  AP
 stop_cpus                            cpu_dead
                                         cpu_set_current_state
                                            spinlock_abtain
                                                up_count--

   wait_for up_count == 1
 enter S3

                                            spinlock_release

Especially, considering the real spinlock release could be delayed
by cache.

Actually, the most content protected by up_count_spinlock is per
cpu data and could be changed without lock. Only left is up_count.
This patchset remove the up_count_spinlock and use atomic API
for up_count changing.

Tracked-On: #1691
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-02 10:43:50 +08:00
Minggui Cao b74720636b HV: add size check for shell log buffer usage
add size check for other hypervisor console command;
they could be overflow for shell log buffer output.

Tracked-On: #1587
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-02 09:13:57 +08:00
Minggui Cao b048835c45 HV: fix bug "vmexit" cmd cause HV console hung
on KBL-NUC when input "vmexit" in hypervisor console,
the console or HV/SOS could be hung, the root cause is:
the log buffer is overflow for 8 CPU cores info.

to resolve the issue:
1. increase the shell log buffer size according to the
physical CPU max number
2. check the snprintf return value, if no buffer left,
just return.

Tracked-On: #1587
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-02 09:13:57 +08:00
Zide Chen 0255e62798 hv: resolve the negative impacts to UOS MSI/MSI-X remapping
After enabling vPCI in hypervisor for vm0, UOS may not able be launched
successfully. Consider this scenario (take MSI-X for example):

- DM makes hypercall to hypervisor to do MSI-X remapping on behalf of
  UOS guests.
- After the hypercall, VHM module in SOS kernel updates the physical
  MSI-X table with the physical Message Data/Addr.
- These MMIO write requests are intercepted by hypervisor, which will
  call ptdev_msix_remap() to do MSI-S remapping.

It may fail due to 2 possible reasons:

1) wrong target VM because:
  hypervisor thinks it's a VM0 MSI-X device but they have been registered
  as UOS guests through HC_SET_PTDEV_INTR_INFO hypercall.

2) wrong ptdev_msi_info->vmsi_data because:
  The virtual MSI-X table is supposed to hold virtual Message data/addr
  but the SOS VHM writes the physical ones to it.

This patch resolves these problems by ignoring the HC_VM_PCI_MSIX_REMAP
hypercall, so virtual and physical Message Data are the same from SOS'
perspective and it won't mess up the virtual PCI device in HV.

Also in HC_SET_PTDEV_INTR_INFO handler, vpci updates the target VM
when the PCI devices are assigned to different VMs.

The UOS' MSI/MSI-X remapping is triggered by hypervisor when SOS (either
DM or VHM) updates the Message Data/Addr.

Tracked-On: #1568
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-01 21:22:10 +08:00
Zide Chen c1d2499e5c hv: enable MSI remapping on vm0
When enabled, hypervisor will handle MSI/MSI-X remapping for SOS.

Tracked-On: #1568
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-01 21:22:10 +08:00
Zide Chen 8c398f7d7e hv: fix issues when msi-x shares same BAR with other data structures
If PBA or other data structures reside in the same BAR with MSI-X,
devicemodel could emulate them and make hypercall SET_MEMORY_REGION
to setup EPT for vm0.

Hypervisor can not intercept the whole range of this BAR, but only
the minimum 4KB pages that cover the MSI-X Table.

Tracked-On: #1568
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-01 21:22:10 +08:00
Zide Chen 5cbe079e24 hv: MSI-X Message Address write fix
Some PCI devices can not accept DWORD write to the MSI-X Table though
PCI Spec allows it:

PCI Spec 3.0 6.8.3.2 MSI-X Configuration: Specifically, software is
always permitted to fill in the Message Address and Message Upper Address
fields with a single QWORD write.

Tracked-On: #1568
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-01 21:22:10 +08:00
Zide Chen dbe156e9f6 hv: fix misrac violations in vcpi code
Fixed the following violations:
- Widening cast on complex integer expression
- Casting operation to a pointer
- Static procedure is not explicitly called in code analysed

Tracked-On: #1568
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-01 21:22:10 +08:00
Zide Chen 5555a2f85d hv: fix bug in sizing MSI-X Table Base Address Register
To sizing a 64-bit BAR, need to form the two 32-bit registers as a
64-bit words, before doing the calculation: inverting all bits and
incrementing by 1.

Tracked-On: #1568
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-01 21:22:10 +08:00
Zide Chen 51977a6d2c hv: Don't check multi-function flag in PCI enumeration
Remove the check to multi-function flag in PCI enumeration because when
this flag is set, Device IDs and Class codes, and this flag may vary
between functions.

We don't assume checking this bit in function 0 is safe enough.

Tracked-On: #1568
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-01 21:22:10 +08:00
Yin Fengwei e32bc9e36d hv: avoid hardcode cs.limit in set_vcpu_regs()
For SOS BSP, we reuse native saved cs.limit
For UOS BSP, we set cs.limit in DM
For AP, we use initialized data from realmode_init_regs.

Tracked-On: #1231
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-11-01 13:11:40 +08:00
Yin Fengwei 0cd85749fe HV: save the cs limit field for SOS
Save the native cs limit and reuse it for SOS cs limit. To remove
the hardcode of cs limit for guest in hypervisor.

Tracked-On: #1231
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-11-01 13:11:40 +08:00
Yin Fengwei 6993fdb3e9 DM: set cs_limit from DM side for UOS
For CS of UOS, we would like to pass all related info (cs attribute,
limit, base) from DM.

Tracked-On: #1231
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-11-01 13:11:40 +08:00
Tianhua Sun b12c7b741b tools: acrn-manager: remove usage of banned APIs
1, replace strlen with strnlen
2, Return value check for strncpy function

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kaige Fu <kaige.fu@intel.com>
2018-11-01 11:22:26 +08:00
Tianhua Sun af760f8dce tools: acrn-manager: refine the usage of api 'snprintf'
Return value check for snprintf function

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kaige Fu <kaige.fu@intel.com>
2018-11-01 11:22:26 +08:00
Tianhua Sun 5493804cab tools: acrnlog: refine the usage of api 'snprintf'
Return value check for snprintf function

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kaige Fu <kaige.fu@intel.com>
2018-11-01 11:22:26 +08:00
Tianhua Sun a2383b06bf tools: acrntrace: remove unsafe api and return value check for snprintf
1, Return value check for snprintf function
2, Replace 'atoi' with 'strtol'

Tracked-On: #1254
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kaige Fu <kaige.fu@intel.com>
2018-11-01 11:22:26 +08:00
Mingqiang Chi 2975f9fa65 hv:Replace dynamic memory with static for sbuf
--Config LOG_BUF_SIZE 256KB for per cpu
--Replace 'calloc' with static array for sbuf
--Rename 'alloc_earlylog_sbuf' to 'init_earlylog_sbuf'
--Remove deadcode sbuf_free

v2-->v3:
 -- put the buffer into per_cpu data structure
v1-->v2:
 -- add 'is_early_logbuf' in percpu data structure used for
    check if need to do 'do_copy_earlylog'

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-01 11:21:49 +08:00
Li, Fei1 9e39732259 hv: l1tf: sanitize mapping for idle EPT
sanitize mapping for idel EPT

Tracked-On: #1672
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-11-01 11:21:15 +08:00
Yonghua Huang fb68468cfd HV: flush L1 cache when switching to normal world
-to avoid information leaking from secure world to
  normal world on platform affected by L1TF.

Tracked-On: #1672
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-11-01 11:21:15 +08:00
Yonghua Huang 34a6336525 HV: enable L1 cache flush when VM entry
- flush L1 cache before VM entry only on platform
   affected by L1TF
 - flush operation is configurable by below MACRO:
    --CONFIG_L1D_FLUSH_VMENTRY_ENABLED

Tracked-On: #1672
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-11-01 11:21:15 +08:00
Yonghua Huang d43d2c9295 HV: add CPU capabilities detection for L1TF mitigation
- detect if current processor is affected by L1TF
  - detect the presence of of "IA32_FLUSH_CMD(MSR 0x10B)
    if processor is affected by L1TF.

Tracked-On: #1672
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-11-01 11:21:15 +08:00
Yonghua Huang 2731628e27 HV: wrap security related CPU capabilities checking
- add a function to detect CPU capabilities for security
   related features, it will print warning messages if
   current ucode can't support the latest security features.

Tracked-On: #1672
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-11-01 11:21:15 +08:00
Jason Chen CJ 25c2d4d781 doc: add l1tf document
Add ACRN L1TF readme document

Tracked-On: #1672
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Tian, Kevin <kevin.tian@intel.com>
2018-11-01 11:21:15 +08:00
santoshkumar b0cac0e67c Samples:Added the Kernel console parameter in boot.
For GP-MRB ACRN using ttyS0 as console,
since this is release bootargs file so ttyS0
will be skipped in booting but needed kernel
console ttyS2 in bootargs to get the Kernel console.

Tracked-On: #1655

Signed-off-by: santoshkumar <santoshkumar.laxminarayan.rai@intel.com>
2018-11-01 09:49:40 +08:00
Binbin Wu 43f6bdb726 hv: vtd: fix device assign failure for partition mode
For partition mode, there is no vm0_domain created for iommu.
In current code, it will return error when try to remove a device
from vm0_domain, which casue failure of device assignment in
partition mode.

Tracked-On: #1680
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-01 09:34:49 +08:00
David B. Kinder 9ae79496be doc: fix section heading in device model hld
Fix incorrect section heading level.

Tracked-on: #1668

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-10-31 13:55:50 -07:00
David B. Kinder 7df70e0c64 doc: update HLD Device Model
Transcode, edit, and upload HLD 0.7 section 4 (Device Model)

Incorporate changes from previously edited acpi-virt.rst and delete
separate doc.

Tracked-on: #1668

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-10-31 13:48:43 -07:00
David B. Kinder 390cc67804 doc: tweak doxygen/known-issues handling
PR #1678 requires slight tweaking of doxygen/known-issues handling to
successfully generate documentation

Tracked-on: #1595
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-10-31 09:13:36 -07:00
Shiqing Gao 60d0a75243 hv: fix integer violations
The operands to shift operations (<<, >>) shall be unsigned integers.

v1 -> v2:
 * replace 12U with CPU_PAGE_SHIFT when it is address shift case.
 * replace 6UL with 0x6UL

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-10-31 15:01:57 +08:00
Tw 4d01e60eda hv: vtd: remove dynamic allocation for iommu_domain
Replace list of iommu_domains with static array

Tracked-On: #861
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-10-31 13:06:07 +08:00
Tw dda08957d7 hv: vtd: remove dynamic allocation for dmar_drhd_rt
Predefine a dmar_drhd_rt table for all possible dmar unit

Tracked-On: #861
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-10-31 13:06:07 +08:00
Tw f05bfeb961 hv: vtd: remove dynamic page allocation for root&ctx table
Preserve pages for each vtd root table and ctx table

Tracked-On: #861
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-10-31 13:06:07 +08:00
Yin Fengwei 1b1338bc04 snprintf: Remove the %o and %p support
%x could be used to replace the %o print option.
%x could be used to replace the %p print option also.

Tracked-On: #1656
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-10-31 13:04:47 +08:00
Binbin Wu 6150c0611f dm: bios: update to version 1.0.1
Bug fix:
- Fix AaaG user build boot failure with  memory size > 2GB and flash unlocked.

Tracked-On: #1659
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2018-10-31 11:30:45 +08:00
Manisha Chinthapally 8c7d471c38 HV: bug fix:possible access to NULL pointer
Return from the function if the NULL pointer is encountered.

Tracked-On : #1409
Signed-off-by: Manisha Chinthapally <manisha.chinthapally@intel.com>
2018-10-31 09:48:56 +08:00
Aviad Nissel 9ba75c55a7 dm: mei: fix firmware reset race.
The FW reset is currently detected from two points upon
a read failure from native read and from the reset
handler.
The fix removes the detection from the mevent rx callback,
leaving a single detection point.
To prevent reset hiccup, hw_ready is not set if a full rescan is
performed, it will be set only when virtio FW will request the FW reset.

Tracked-On: #1632
Signed-off-by: Aviad Nissel <aviad.nissel@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
2018-10-31 09:43:45 +08:00
Alexander Usyskin 5f41d4a8d3 dm: mei: check return value of vmei_host_client_to_vmei()
vmei_host_client_to_vmei() may return NULL we need to check
for the return value.

Tracked-On: #1630
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
2018-10-31 09:43:45 +08:00
Tomas Winkler b4fbef4659 dm: mei: destroy mutex attribute on error path
Simplify the flow by adding mutex_type variable
and call pthread_mutexattr_destroy() on the error path.

Tracked-On: #1630
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
2018-10-31 09:43:45 +08:00
Alexander Usyskin 8abc931791 dm: mei: set addresses in the hbm disconnect reply
MEI HBM the disconnect replay doesn't have the address set,
breaking the protocol, fix the issue.

Tracked-On: #1570
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2018-10-31 09:43:45 +08:00
Yonghua Huang 6bb3d0484c hv: remove deprecated functions declartion
Below functions are deprecated, remove them from hypercall.h
hc_assert_irqline()/hc_deassert_irqline()/hc_pulse_irqline()

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-10-31 09:40:07 +08:00
Xiaoguang Wu a0ace7254d DM USB: xHCI: fix process logic of TRB which has zero data length
Accoring to xHCI spec, there are some TRBs with zero data length
which used to pass command to xHCI. In the DM, those TRBs should
not be sent to native device through libusb. The logic in the
current implentation fails to process some corner cases, this
patch is used to fix it.

Tracked-On: #1639
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-10-31 09:08:53 +08:00
Minggui Cao 6266dd014a DM: correct memory allocation size for UOS
on 8GB MRB: cat /proc/meminfo|head -n 1|awk '{print $2}'
it is: 7993388, it is not 8000000, so set it compare
with 7500000, then it can allocate 6GB to UOS.

Tracked-On: #1657
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-10-31 09:08:13 +08:00
David B. Kinder ac5b46eba5 doc: update rest of hypervisor HLD sections
Transcode, edit, and upload HLD 0.7 section 3.10 (PM in hypervisor),
3.11 (Console, shell, vUART), 3.12 (Hypercall/VHM upcall), and
3.13 (Compile-time config)

Also scan/replace UTF-8 punctuation missed in previous PRs.

Add anchor targets in referenced docs.

Tracked-on: #1648

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-10-30 11:20:09 -07:00
David B. Kinder 97c8c16f6a doc: fix misspellings in hld docs
can and fix misspellings missed during normal review

Tracked-on: #1648

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-10-30 08:58:01 -07:00