1
0
mirror of https://github.com/projectacrn/acrn-hypervisor.git synced 2025-05-04 14:36:55 +00:00
Commit Graph

5730 Commits

Author SHA1 Message Date
Yonghua Huang
ec685509a6 hv: minor coding style fix in list.h
To add brakets for '(char *)(ptr)' in MACRO
 container_of(), which may be used recursively.

Tracked-On: 
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-15 14:27:39 +08:00
Yonghua Huang
4da04e3f04 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: 
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-15 11:53:36 +08:00
Yonghua Huang
7caf896cb8 dm: validate inputs in vq_endchains
inputs shall be validated to avoid NULL pointer access.

Tracked-On: 
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-15 11:53:36 +08:00
Shuo A Liu
b1bb8ea4f1 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: 
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-15 11:53:36 +08:00
Li Fei1
0436085268 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: 
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2021-07-15 11:53:36 +08:00
Jie Deng
fc62ebfa85 dm: NULL check of vq->used in virtio_net_ping_rxq
Add a check on this place to avoid NULL access issue.

Tracked-On: 
Signed-off-by: Jie Deng <jie.deng@intel.com>
2021-07-15 11:53:36 +08:00
dongshen
0ac2e21f20 hv: add support to assign 3rd non-contiguous HPA regions for logical partition scenario
Currently acrn supports 2 non-contiguous HPA regions (HPA1 and HPA2), extend
the code to support 3rd non-contiguous HPA region (HPA3) for logical partition scenario
(hybrid scenario is not supported)

To keep things simple, current design has the following assumptions for
ve820 and ept mapping:
 1. HPA2 will always be placed after HPA1
 2. HPA3 will always be placed after HPA2
 3. HPA1/HPA2/HPA3 don’t share a single ve820 entry.
  (Create multiple entries if needed but not shared)

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2021-06-08 09:30:17 +08:00
dongshen
16d517a84d acrn-config: add support to assign 3rd non-contiguous HPA regions for logical partition scenario
Currently config tool supports 2 non-contiguous HPA regions (HPA1 and HPA2), extend
the code to support 3rd non-contiguous HPA region (HPA3) for logical partition scenario
(hybrid scenario is not supported)

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2021-06-08 09:30:17 +08:00
David B. Kinder
6f3dfb8a59 doc: tweak doc config for v2.3 for CI tool mismatch
All releases of ACRN use the same CI docker image for testing the
documentation build. This creates a problem because some features used
in older ACRN releases are deprecated or behave differently with newer
versions of Sphinx and other tools.  Add a check for the Sphinx version
to account for this, and update the .known-issues patterns for duplicate
declarations.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2021-06-06 14:04:18 -04:00
Jian Jun Chen
5356fdc520 hv: ivshmem: BAR0 size should be 256 Bytes
ivshmem spec says that the size of BAR0 is 256 bytes. Windows
ivshmem driver will check the size of BAR0. It will refuse to
load the ivshmem driver if BAR0 size is not 256.
For post-launched VM hv land ivshmem BARs are allocated by
device model. For pre-launched VM hv land ivshmem BARs are
allocated by acrn-config tool. Both device model and acrn-config
tool should make sure that the BAR base addr are aligned to 4K
at least.

Tracked-On: 
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-03-25 14:35:28 +08:00
Jian Jun Chen
6c18402a13 dm: align bar base addr to PAGE_SIZE at least
PCI spec said that BAR base should be naturally aligned. But on
ACRN if the bar size < PAGE_SIZE, BAR base should be aligned with
PAGE_SIZE. This is because the minimal size that EPT can map/unmap
is PAGE_SIZE.

Tracked-On: 
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-03-25 14:35:28 +08:00
Yin Fengwei
cfc3017a62 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: 
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-01-20 11:22:53 +08:00
wenlingz
b6e24ea4b1 version:v2.3
Signed-off-by: wenlingz <wenling.zhang@intel.com>
2020-12-03 09:51:40 +08:00
David B. Kinder
0859836756 doc: update release branch with new docs
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2020-12-02 17:44:34 -08:00
Li Fei1
d57a213242 hv: hypercall: hot fix call assign/deassign mmiodev could crash hv
If we assign the mmio device address and size maliciously, this may crash
the HV, SOS even the UOS. This patch is a hot fix. The formal one needs
the config tool to configure the mmio device which we could pass through
and the HV check the mmio device by it.

Tracked-On: 
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2020-11-27 10:44:41 +08:00
Peter Fang
ee07a439db misc: add the s5_trigger.sh script
Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
2020-11-26 14:18:06 +08:00
Yang Yu-chu
ec8af42ab3 acrn-config: update default pci_dev.c
update all default pci_dev.c under
misc/vm_configs/scenarios/<scenario>/<platform> for non-xml compilation

Tracked-On: 
Signed-off-by: Yang Yu-chu <yu-chu.yang@intel.com>
2020-11-26 09:44:28 +08:00
Jie Deng
79348c431f dm: virtio_console: read only when the virtqueue is ready.
The read should not continue if the virtqueue is not ready.

Tracked-On: 
Signed-off-by: Jie Deng <jie.deng@intel.com>
2020-11-26 09:32:15 +08:00
Peter Fang
13348793b5 misc: life_mngr: prevent log flooding after SOS socket is closed
After the SOS socket is closed, read() returns instantly with a return
value of 0. This causes life_mngr to flood the log file with the
following messages:

    received msg []
    received msg []
    received msg []
    ...

Exit the program directly now if this is detected.

Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
2020-11-26 09:27:02 +08:00
Jie Deng
07b8466b15 hv: disable AC for split-lock by default.
This patch disables the AC for split-lock check.

Tracked-On: 
Signed-off-by: Jie Deng <jie.deng@intel.com>
2020-11-24 13:08:51 +08:00
Yang,Yu-chu
2196bc7f41 doc: update the steps of enable ivshmem
To enable the hv_land ivshmem for post-launched vm, the lanch script
needs to be cofigured accordingly.

Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2020-11-23 00:04:50 -08:00
Liu Long
288a73fcf1 DM: check then return value of paddr_guest2host
paddr_guest2host may return NULL, this patch checks the return value
to avoid null pointer dereference.

Signed-off-by: Liu Long <long.liu@intel.com>
Tracked-On: 
2020-11-17 13:35:32 +08:00
Tomas Winkler
e59a3c92ce dm: virtio: check for paddr_guest2host return value
paddr_guest2host can return NULL, but code paths in virtio
are not checking the return value.
_vq_record() initializes iov_base pointer using paddr_guest2host()
but there is nothing in the flow that checks for NULL.
Chane _vq_record to return -1 in case the address translation
has failed.

Tracked-On: 
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-11-17 13:34:37 +08:00
Shixiong Zhang
d7f9420b07 acrn-config: modify the cmd args in pre-launched rt xml
add the right cmd args provided by Ronnie.

Tracked-On: 

Signed-off-by: Shixiong Zhang <shixiongx.zhang@intel.com>
2020-11-17 10:19:14 +08:00
Yonghua Huang
c842156a79 hv: fix nr_bars for hv-land ivshmem devices
Memory BAR of ivshmem device is 64-bit, 2 BAR registers
 are used, counting in one 32-bit MMIO bar and and one
 32-bit vMSIX table bar, number of bars "nr_bars" shall
 be 4 instead of 3.

Tracked-On: 
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2020-11-17 09:32:54 +08:00
Yonghua Huang
6225f690f3 hv: bugfix for hv-emulated device de-init
- fix bug in 'hcall_destroy_vdev()', the availability of
   vpci device shall be checked on 'target_vm".

 - refine 'vpci_update_one_vbar()' to avoid potential NULL
   pointer access.

Tracked-On: 
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2020-11-16 10:55:04 +08:00
Shuang Zheng
c1451f4721 acrn-config: update tpm config source code for hybrid_rt on ehl
enable tpm2 config source code for hybrid_rt scenario on ehl board.

Tracked-On: 

Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
2020-11-13 15:45:42 +08:00
Shuang Zheng
47a2e9332f acrn-config: enable tpm for hybird_rt on ehl
enable tpm for hybrid_rt scenario on ehl board.

Tracked-On: 

Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
2020-11-13 15:45:42 +08:00
Jian Jun Chen
80f905f217 hv: pci: Hide PCI bridge 00:1c.0 from SOS
It is found that SOS will reset the PCI devices under PCI
bridge 00:1c.0 when 00:1c.0 is exposed to SOS. If a PCI
device under 00:1c.0 is passed through to pre-launched VM,
it will be reset by SOS at startup hence the passthrough
will not work properly. This patch provides a workaround
by hiding PCI bridge 00:1c.0 from SOS in this case.

Tracked-On: 
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
2020-11-13 15:33:42 +08:00
Shixiong Zhang
569e05ef74 acrn-config: modify the cmd args in pre-launched rt xml
add the right cmd args provided by Ronnie.

Tracked-On: 

Signed-off-by: Shixiong Zhang <shixiongx.zhang@intel.com>
2020-11-12 16:50:14 +08:00
Tao Yuhong
bcbd0dcd81 Fix: do not need to hide IO 0x3f8 for SOS on EHL
when HW platform like EHL use mmio type serial, do not need to hide
serial IO port for SOS

Tracked-On: 
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2020-11-12 11:40:05 +08:00
Tao Yuhong
6f447ba626 HV: hide CONFIG_SERIAL_PIO_BASE IO port for SOS
Always trap for accessing IO port at CONFIG_SERIAL_PIO_BASE(0x3f8).

SOS will trap at IO 0x3f8 access because vuart[0]. When HW platform
has this serial IO port, and HV use it as debug shell, If vuart[0]
is not set, SOS & HV console input/output are mixed up.

So SOS should always trap at CONFIG_SERIAL_PIO_BASE

Tracked-On: 
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2020-11-11 14:04:45 +08:00
Tao Yuhong
f37ef14798 Fix: HV: VM OS failed to assign new address to pci-vuart BARs
When wrong BAR address is set for pci-vuart, OS may assign a
new BAR address to it. Pci-vuart BAR can't be reprogrammed,
for its fixed value.

Remove the fixed value of pci-vuart.

Tracked-On: 
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2020-11-11 09:50:48 +08:00
Tao Yuhong
07a52bb40c TGL: Fix sos can't boot with 6 pci-vuarts
Increase CONFIG_MAX_EMULATED_MMIO_REGIONS to 32, for more pci-vuarts.
Each pci-vuart vdev need 2 mmio BARs, if there are 8 pci-vuarts, they
need emulate 16 mmio regions.

But by default CONFIG_MAX_EMULATED_MMIO_REGIONS=16, that is not enough.

Tracked-On: 
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2020-11-10 13:37:48 +08:00
Peter Fang
ff4cc7fbb1 doc: add an example for OVMF split images
Add an example to use "code=" and "vars=" in the dm parameters to launch
with OVMF split images.

Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2020-11-10 13:36:00 +08:00
Peter Fang
b8a0730132 dm: support OVMF split images
In addition to a single OVMF image (OVMF.fd), split images
(OVMF_CODE.fd, OVMF_VARS.fd) can be used to facilitate VM management.

From the OVMF Whitepaper:

  The variable store and the firmware executable are also available in
  the build output as separate files entitled: "OVMF_VARS.fd" and
  "OVMF_CODE.fd". This enables central management and updates of the
  firmware executable, while each virtual machine can retain its own
  variable store.

An example to launch acrn-dm with the split images:

  --ovmf code=/usr/share/acrn/bios/OVMF_CODE.fd, \
  vars=/usr/share/acrn/bios/OVMF_VARS.fd

v1 -> v2:
- use memory-mapped file I/O for writeback
- use fcntl to lock OVMF image files

Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-11-10 13:36:00 +08:00
Yang,Yu-chu
0b29690229 acrn-config: insert legacy vuart0 base by its enablement status
The legacy vuart0 of any VMs inserts its base address declaration
anyway without checking whether it's disabled or enabled, and the
com base is hardcoded no matter what is specified in xmls.

Pull the legacy vuart enablement status based on scenario xml.

This reverts commit a8fe9b906a

Tracked-on: 
Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
2020-11-06 16:11:30 +08:00
Yang,Yu-chu
c25f9ee0f0 acrn-config: insert vbdf in hex format and vuart vbdf logic
Bug fix:
1. The bdf were inserted in decimal. Fix it with hexadecimal
format.
2. The vuart vbdf will only take the dev which no used bdf has
the same dev. For example: If 00:01.1 is in used but not 00:01.0,
vuart vbdf will skip 00:01.0 and look for 00:02.0, 00:03.0 and so on.

Tracked-On: 
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2020-11-06 16:10:09 +08:00
Peter Fang
63593694e4 hv: remove vm_lock in hcall_destroy_vm()
Hypercall handlers for post-launched VMs automatically grab the vm_lock
in dispatch_sos_hypercall(). Remove the use of vm_lock inside the
handler.

Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
2020-11-06 11:48:47 +08:00
Sun Peng
d8b3ca18f6 DM: gvt: Identical mapping for GPU DSM
Windows graphic driver obtains DSM address from in-BAR mmio register
which has passthroughed. Not like the other platforms obtained from
pci configure space register which has virtualized. So TGL has to
keep identical mapping to avoid trap mmio BAR to do the emulation.

To keep simple, this patch hardcode the TGL DSM region in vE820
table, this will cause memory waste here. In the near future, we
need refine the entire vE820 logic as it is hard to maintained
due to many reserved regions have introduced in recently.

Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Tracked-On: 
2020-11-04 11:10:59 +08:00
Yang,Yu-chu
5d13f6e344 acrn-config: removed_nested returns None instead return Error
qemu xml has no devices list. Tool will receive the empty devices
list while parsing the "platform" xml. Remove the error of resolved
nested mmio address window that the input couldn't be None. Simply
return an None list.

Tracked-On:#5454
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2020-11-04 10:33:07 +08:00
Liu Long
0c6682e845 ACRN:DM:xHCI Fix the unsigned integer conversion bug
When libusb_control_transfer function return a negative number, because
 the function clear_uas_desc's argument is unsigned int this will cause
 unsigned integer conversion.

Tracked-On: 
Signed-off-by: Liu Long <long.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-11-04 10:32:23 +08:00
dongshen
49b6e12895 hv: add support for shutdown for pre-launched VMs
Currently, ACRN only support shutdown when triple fault happens, because ACRN
doesn't present/emulate a virtual HW, i.e. port IO, to support shutdown. This
patch emulate a virtual shutdown component, and the vACPI method for guest OS
to use.

Pre-launched VM uses ACPI reduced HW mode, intercept the virtual sleep control/status
registers for pre-launched VMs shutdown

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2020-11-04 10:31:30 +08:00
dongshen
43d7eb5d76 hv: fix out-of-date comments related to pre-launched VMs rebooting
Like post-launched VMs, for pre-launched VMs, the ACPI reset register
is also fixed at 0xcf9 and the reset value is 0xE, so pre-launched VMs
now also use ACPI reset register for rebooting.

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2020-11-04 10:31:30 +08:00
dongshen
0b217dd3d1 acrn-config: specify kernel boot argument 'reboot=acpi' for pre-launched VMs
Add the 'reboot=acpi' kernel boot argument for pre-launched VMs

Add the code to sanity check if 'reboot=acpi' is specified in the
scenario files

If hardware reduced ACPI is detected, by default, Linux will set the reboot type to
use EFI for rebooting. "reboot=acpi" sets the reboot type to use ACPI for rebooting.

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2020-11-04 10:31:30 +08:00
dongshen
9491c2e0e5 acrn-config: build a hardware-reduced only ACPI
Change ACPI version from V3 to V5 to support hardware-reduced ACPI, which
is a V5 feature

Remove/obsolete the PM1X related stuff as they are not used for hardware-reduced
ACPI

Add the _S5 method in DSDT table

Using hardware-reduced mode allows to use a much simpler form of ACPI that
does not require supporting the legacy of previous versions of the specification
such as SCI IRQ.

Hardware-reduced mode is specified by setting the Hardware Reduced (HW_REDUCED_ACPI)
flag in FADT table.

If the HW_REDUCED_ACPI flag in the FADT table is set, OSPM will ignore fields related
to the ACPI HW register interface such as the PM1x control register. Instead, sleep
control/status registers can be used for system sleep state entry on hardware-reduced
ACPI systems.

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2020-11-04 10:31:30 +08:00
dongshen
7b2494e292 acrn-config: specify valid ACPI reset register address and value in FADT table
So that guest VM can recognize and use ACPI reset register to reboot

No need to specify "Flags (decoded below)" in FADT template, iasl will
calculate and fill in this flag for us

Tracked-On: 
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2020-11-04 10:31:30 +08:00
Peter Fang
3cc51a8254 hv: console: switch back to HV shell on VM pause
A VM may transition to VM_PAUSED state while its console is being used.

Jump back to the HV shell if this happens so the console does not appear
stuck.

Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-11-04 10:31:30 +08:00
Peter Fang
06838df53b hv: pm: support shutting down multiple VMs when pCPUs are shared
More than one VM may request shutdown on the same pCPU before
shutdown_vm_from_idle() is called in the idle thread when pCPUs are
shared among VMs.

Use a per-pCPU bitmap to store all the VMIDs requesting shutdown.

v1 -> v2:
- use vm_lock to avoid a race on shutdown

Tracked-On: 
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-11-04 10:31:30 +08:00
acrnsi-robot
14b26d2170
Merge pull request from szhen11/disable_psram
acrn-config: disable psram config
2020-11-03 17:51:28 +08:00