Commit Graph

5264 Commits

Author SHA1 Message Date
Liu,Junming
ad5e1cca0e hv: refine the VMCS io bitmap handling when pass-thru PIO bar
In current design, when pass-thru dev,
for the PIO bar, need to ensure the guest PIO start address
equals to host PIO start address.
Then set the VMCS io bitmap to pass-thru the corresponding
port io to guest for performance.

But malicious guest may reprogram the PIO bar,
then hv will pass-thru the reprogramed PIO address to guest.
This isn't safe behavior.

Here only pass-thru the host physical device PIO to guest.
If guest regrogram the PIO bar, just update the virtual bar only.
Currently, we don't support PIO bar reprogramming,
if guest reprogram the PIO bar, guest should take responsibility itself

When init the pass-thru dev PIO bars, set the VMCS io bitmap.
setup_io_bitmap is called before init pass-thru dev to
initiailize the io bitmap, so don't need to
call deny_guest_pio_access when deinit pass-thru dev.

v1 -> v2:
	* set the VMCS io bitmap when init pass-thru devices
	to migrate redoing allow_guest_pio_access()/deny_guest_pio_access().

Tracked-On: #6508

Signed-off-by: Liu,Junming <junming.liu@intel.com>
2021-09-28 15:01:21 +08:00
Liu,Junming
7fe145051c dm: identical mapping of pass-thru dev PIO bar
For pass-thru dev PIO bar,keep identical mapping

Tracked-On: #6508

Signed-off-by: Fei Li <fei1.li@intel.com>
2021-09-28 15:01:21 +08:00
Liu Long
069c7aceeb dm: fix fault Injection into VirtIO console backend
CVE# CVE-2021-23905
 Add Null pointer check in init vq ring and add vq ring descriptor
 check in case cause Nullpointer exception.

Tracked-On: #5355
Signed-off-by: Liu Long <long.liu@intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-02 14:26:39 +08:00
Jie Deng
f2331e71bc virtio: add virtio callbacks check
CVE# CVE-2021-23904
We can only call these callbacks when they are not NULL.

Tracked-On: #5342

Signed-off-by: Jie Deng <jie.deng@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-02 14:26:39 +08:00
Jie Deng
836c531630 dm: virtio_console: read only when the virtqueue is ready.
CVE# CVE-2021-23902
The read should not continue if the virtqueue is not ready.

Tracked-On: #5544
Signed-off-by: Jie Deng <jie.deng@intel.com>
2021-07-02 14:26:39 +08:00
Yonghua Huang
1f17d0f4ac DM: xHCI: Check trb pointer before use it
The trb pointer may be NULL when get the address from user space, add
the pointer check before use the trb.

Tracked-On: #6172
Signed-off-by: Liu Long <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-07-02 09:47:01 +08:00
Yonghua Huang
eeffdb4833 dm: validate inputs in vq_endchains
inputs shall be validated to avoid NULL pointer access.

Tracked-On: #6129
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-02 09:47:01 +08:00
Shuo A Liu
e00c4176e1 dm: Reset virtio device before release
With virtio polling mode enabled, a timer is running in the virtio
backend service. And the timer will also be triggered if its frondend
driver didn't do the device reset in shutdown. A freed virtio device
will be accessed in the polling timer handler.

Do the virtio reset() callback specifically to clear the polling timer
before the free.

Tracked-On: #6147
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-02 09:47:01 +08:00
Li Fei1
805f103d1a dm: rb: only free rb_entry when we remove this entry from the rb tree
Only free rb_entry when we remove this entry from the rb tree, otherwise, a
page fault would trigger when next rb itreation would access the freed rb_entry.

Tracked-On: #6056
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2021-07-02 09:47:01 +08:00
Jie Deng
cf90f060c1 dm: NULL check of vq->used in virtio_net_ping_rxq
Add a check on this place to avoid NULL access issue.

Tracked-On: #6100
Signed-off-by: Jie Deng <jie.deng@intel.com>
2021-07-02 09:47:01 +08:00
Yin Fengwei
e301c61fb3 hv: ptirq: Shouldn't change sid if intx irq mapping was added
Now, we use hash table to maintain intx irq mapping by using
the key generated from sid. So once the entry is added,we can
not update source ide any more. Otherwise, we can't locate the
entry with the key generated from new source ide.

For source id change, remove_remapping/add_remapping is used
instead of update source id directly if entry was added already.

Tracked-On: #5640
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-01-20 11:23:17 +08:00
Sun Peng
54b8d4b43d dm: uart: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
e8d52d46bf dm: blockif: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
ebca2d5ac1 dm: ioc: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
2807487273 dm: timer: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
a692df46c1 dm: tpm: Convert print output to acrn-dm logger
Refine the DPRINTF/WPRINTF to pr_* based log interface for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
57dd678632 dm: rbmp: Convert print output to acrn-dm logger
Refine the DPRINTF/WPRINTF to pr_* based log interface for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
1dee884654 dm: usb: Convert print output to acrn-dm logger
Refine the UPRINTF to pr_* based log interface for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
e8ab23d648 dm: pci_passthrough: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
abdab52c63 dm: npk: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
3f0fe0765c dm: gvt: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
549e3c74b6 dm: gsi: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
fa668ac010 dm: pci_core: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
8c73798f25 dm: ahci: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
0e19d132ff dm: virtio: Convert console print output to acrn-dm logger
Refine the DPRINTF/WPRINTF to pr_* based log interface instead of printf directly.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Sun Peng
71c36f19d1 dm: core: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-18 16:33:40 +08:00
Minggui Cao
25fff0c21a add flag to control vmexit sample in HV bootargs
for vmexit data sampling could affect HV performace profiling,
so set it disabled by default.

add a flag in HV bootargs to control vmexit data sampling.

Tracked-On: #5232
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2020-08-26 16:55:27 +08:00
Minggui Cao
ea2650918b sample vmexit data per-pCPU and per-vCPU
this feature is used to sample vmexit data as per physical CPU
and per virutal CPU of VM, command used in HV console as following:
  1. vmexit clear --> to clear current vmexit buffer
  2. vmexit -->output current vmexit info

also it gives the reschedule data as per-pcpu.

Tracked-On: #5232
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2020-08-26 16:55:27 +08:00
Victor Sun
978f899029 HV: move vm configuration check to pre-build time
This patch will move the VM configuration check to pre-build stage,
a test program will do the check for pre-defined VM configuration
data before making hypervisor binary. If test failed, the make
process will be aborted. So once the hypervisor binary is built
successfully or start to run, it means the VM configuration has
been sanitized.

The patch did not add any new VM configuration check function,
it just port the original sanitize_vm_config() function from cpu.c
to static_checks.c with below change:
  1. remove runtime rdt detection for clos check;
  2. replace pr_err() from logmsg.h with printf() from stdio.h;
  3. replace runtime call get_pcpu_nums() in ALL_CPUS_MASK macro
     with static defined MAX_PCPU_NUM;

The BOARD/SCENARIO parameter check and configuration folder check is
also moved to prebuild Makefile.

Tracked-On: #5077

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-08-12 15:24:42 +08:00
Victor Sun
070ac3c265 HV: remove sanitize_vm_config function
Remove function of sanitize_vm_config() since the processing of sanitizing
will be moved to pre-build process.

When hypervisor has booted, we assume all VM configurations is sanitized;

Tracked-On: #5077

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-08-12 15:24:42 +08:00
Victor Sun
e7d0c20709 HV: init vcpu affinity of SOS VM when launch VMs
Previously the initialization of SOS vCPUs is done by sanitize_vm_config()
before call launch_vms(), once sanitize_vm_config() is moved to pre-build,
we need to do the initialization in launch_vms();

Tracked-On: #5077

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-08-12 15:24:42 +08:00
Junming Liu
731e9182d6 DM: PT: Add "d3hot_reset" sub-parameter for passthrough device
Some passthrough devices have no reset mechanisms which cause the device stay
in unknown status during boot/reboot flow. And such unknown status cause
unexpected behaviors in the guest. Except the ordinary reset mechanisms
like FLR, we can utilize enter/exit D3cold as the reset that D3cold will
power gate the entire hardware. But the D3cold is implemented as ACPI
method which has no user interface in the SOS side. But the D3cold is
implemented as ACPI method which has no user interface in the SOS side.
But base on our experience, some devices can utilize D3hot instead of
D3cold. But it is not useful for all PCI devices as the power status
of D3hot is implementation defined.
Provide one new API to program PowerState(D0/D1/D2/D3hot) in PMCSR
register.
Add "d3hot_reset" sub-parameter for passthrough device to enable utilize
enter/exit D3hot flow to implement reset mechanisms.

Tracked-On: #5067

Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2020-08-11 16:07:44 +08:00
Xiaoguang Wu
607a4221ac hv: fix stos and stosq asm instruction emulation error
This patch is used to fix asm instruction error such as stos and stosq.

Tracked-On: #5165
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
2020-08-11 14:18:27 +08:00
Binbin Wu
b1cbe39164 config: add GUEST_FLAG_PMU_PASSTHROUGH to DM_OWNED_GUEST_FLAG_MASK
Allow DM to set GUEST_FLAG_PMU_PASSTHROUGH to passthrough PMU to
a VM.

Tracked-On: #5132
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2020-08-06 14:03:55 +08:00
Binbin Wu
08c079693f dm: vm: add option to enable pmu passthrough
Add "--pmu" to enable PMU passthrough.

Tracked-On: #5132
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2020-08-06 14:03:55 +08:00
Binbin Wu
547428021a hv: pmu: passthrough pmu to vm when GUEST_FLAG_PMU_PASSTHROUGH set
Add a new guest_flag GUEST_FLAG_PMU_PASSTHROUGH to indicate whether to
passthrough Performance Monitor Unit (PMU) to a VM or not.
If GUEST_FLAG_PMU_PASSTHROUGH is set for a VM, passthrough PMU.

Currently, PEBS is not supported.

Tracked-On: #5132
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2020-08-06 14:03:55 +08:00
Victor Sun
77775c9297 HV: correct RO mask of MSI cap structure
In MSI Capability Structure, bit 7 (64 bit address capable) of MSICTRL
is RO;

Tracked-On: #5125

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Li Fei <fei1.li@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-08-05 13:38:15 +08:00
Wei Liu
8570ff71ba acrn-config: refine mac seed for launch config
Refine mac seed when generating launch script.

Tracked-On: #5039
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
2020-07-23 11:31:02 +08:00
Wei Liu
69af2f4be7 acrn-config: generate '-s 1:0,lpc ' for non-hart rt in launch script
Generate '-s 1:0,lpc ' for none Hart RT in launch script.

Tracked-On: #5049
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
2020-07-20 09:55:20 +08:00
Wei Liu
64896ac982 acrn-config: minor fix mac seed for launch config
Minor fix for mac seed when generating launch script.

Tracked-On: #5039
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
2020-07-16 11:38:07 +08:00
Qian Wang
7c94d8c411 HV: restrict conditions to assign/deassign pcidev
This patch is ported from mainline branch to v2.0 branch to fix
potential service VM hang issue when fuzzing hypercalls.

hv: hypercall: restrict the condition to assign/deassign a pci device to
a post-launched VM for safety

For the safety of post-launched VMs, pci devices assignments should
occur only when VM is being created (at VM_CREATED STATUS), and pci
devices de-assignment should occur only when VM is being created or
shutdown/reset (at VM_CREATED or VM_PAUSED status)

Tracked-On: #5024
Acked-by: Eddie Done <eddie.dong@intel.com>
Reviewed-by: Li Fei <Fei1.Li@intel.com>
Signed-off-by: Wang Qian <qian1.wang@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2020-07-13 10:48:25 +08:00
Victor Sun
1a167ca0b0 HV:BOARD_ENABLE: add whl-phx-i7 configs code
add whl-phx-i7 configuration code support;

Tracked-On: 4998

Signed-off-by: Victor Sun <victor.sun@intel.com>
2020-07-02 15:00:55 +08:00
Victor Sun
f269c2e020 HV:BOARD_ENABLE: add whl-phx-i7 xmls
add whl-phx-i7 board xml and its industry scenario xml into repo;

Tracked-On: #4998

Signed-off-by: Victor Sun <victor.sun@intel.com>
2020-07-02 15:00:55 +08:00
Yin Fengwei
7ae20c970b debug: BOARD_ENABLE: update the debug serial port info of SOS
Currently, we always assign 0x3F8 as port base io address for
emualted COM1 of SOS.

But in some board, it use serial port which has other base io
address for debugging purpose. And this serial port info is also
exposed to SOS by ACPI table.

In this case, SOS could access the debugging serial port because
it could see the port from ACPI table and conflict with ACRN.

To mitigate this issue, we could let emulated COM1 of SOS to use
native debugging serial port base io port and irq info.

Tracked-On: #4998
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2020-07-02 09:40:52 +08:00
Wei Liu
ae748704c0 acrn-config: extend the max msix table number to 64
Config tool should keep aligning with Kconfig default value for
MAX_MSIX_TABLE_NUM.

Tracked-On: #4994
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
2020-06-30 16:17:11 +08:00
Yin Fengwei
8d8c36b340 kconfig: extend the max msix table number to 64
There are some devices (like Samsung NVMe SSD SM981/PM981 which has 33 MSIX tables)
which have more than 16 MSIX tables. Extend the default value to 64 to handle them.

Tracked-On: #4994
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2020-06-30 16:17:11 +08:00
wenlingz
9c1f1a0dba version:v2.0
Signed-off-by: wenlingz <wenling.zhang@intel.com>
2020-06-27 09:21:22 +08:00
David B. Kinder
ddc769f594 doc: update release_2.0 branch with doc changes
Update the working release_2.0 branch with doc updates made since the
code feature freeze two weeks ago.  (This is an update of all docs
changed in master since then, instead of doing cherry-picks of the
individual doc PRs/commits).

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2020-06-24 09:40:54 -07:00
Li Fei1
e0a101d9f0 hv: vpci: a minor fix about is_zombie_vf
Now we check whether a device is zombie by the ->user != NULL.

Tracked-On: #4550
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2020-06-21 11:56:07 +08:00
yuhong.tao@intel.com
2100ef0b50 HV: Fix split-locked access detection is disabled by default
The commit 'HV: Config Splitlock Detection to be disable' allows
using CONFIG_ENFORCE_TURNOFF_AC to turn off splitlock #AC. If
CONFIG_ENFORCE_TURNOFF_AC is not set, splitlock #AC should be turn on

Tracked-On: #4962
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2020-06-19 14:44:26 +08:00