Commit Graph

948 Commits

Author SHA1 Message Date
Kaige Fu 356bf18491 DM: Get max vcpu per vm from HV instead of hardcode
This patch tries to fetch max vcpu per vm from HV instead of hardcode in DM.

Tracked-On: #3116
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-15 09:30:59 +08:00
lijianpi d9717967d7 dm:add grep -w option for uos launch sh
for vm_name  with vxworks_vm1  or zephyr_vm1 or vm1
grep "vm1" will match three of them, add -w option fix this issue
Tracked-On:#3081
Signed-off-by: zhangyun <yunx.zhang@intel.com>
2019-05-14 09:15:29 +08:00
Jian Jun Chen 4c28a37440 dm: add sample script to launch Windows as guest
This patch adds one sample script to launch Windows as guest.

Tracked-On: #3099
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-05-13 14:43:07 +08:00
Liu Xinyun d9e6cdb593 dm: not register/unregister gvt bar memory
AcrnGT traps and intercepts the memory region defined by PCI bar in
service OS kernel driver. No need to register the bar associated region
in dm. By the way, some OS changes BAR start address and there is no
mechanism to reflect the gvt changes back to dm. It causes problem that
other devices may register new region which falls in GVT `old` region,
and leads to hypervisor crash.

v4: Add FIXME tag. It's a short term solution before migrated to OVMF
v3: rewording the comments
v2: removed unnecessary braces and use printf to log (Peter)

Tracked-On: #2976

Reviewed-by: He, Min <min.he@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: Liu Xinyun <xinyun.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-09 17:28:16 +08:00
Kaige Fu 0cadc16b8b DM: Add one sample script to launch VxWorks as guest
This patch add one sample script to launch VxWorks as guest.

Tracked-On: #3069
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-05-07 11:40:35 +08:00
Vijay Dhanraj 71b56e0eed DM: Virtio-Blk Rescan
This patch adds support to trigger rescan of virtio-blk device by the
guest VM. This is an alternate to hot-plugging virtio-blk device.
This feature stems from the kata requirement, which hot-plugs container
rootfs after the VM is launched.

As part of virtio-blk rescan,
1. Update the backing file for the virtio-blk device with valid file.
   Basically update the empty file (with dummy bctxt) that was passed
   during VM launch.
2. Update virtio-blk device configurations for udpated backing file.
3. Update size associated with valid backing file in the config space.
4. Notify guest OS, of the new config change.
5. On this notification, guest will do the following.
	(i). Update virtio-blk capacity.
 	(ii). Revalidate the disk.
 	(iii). Identify the newly plugged block device.

v5 -> v6:
- Removed use of dummy file and added a new parameter "nodisk"
  to virtio-blk which indicates user wants to create a virtio-blk
  device with dummy backend.
- Moved vm_monitor_rescan from pci core to virtio-blk as it currently
  applies to only virtio-blk.

v4 -> v5:
- Reverted back logic, so that blkrescan is only supported when
  VM is launched with empty backend file.

v3 -> v4:
- Close block context before allocating a new one
- Allow backend filepath  with additional options to be more generic
- Remove blank lines introduced as part of previous patches.

v2 -> v3:
- Renamed vdev ops vdev_blk rescan to vdev_rescan
- Renamed montior ops virtio_blkrescan_ops to virtio_rescan_ops
- Consolidated virtio-blk configuration specific part into
  a separate function
- Removed size requirement in acrnctl command.

v1 -> v2:
- Added more comments in the code.
- Renamed APIs from displug to blkrescan, inline with acrnctl cmd.
- Split the patch into two. This corresponds to changes in acrn-dm.

Tracked-On: #3051
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-07 09:08:50 +08:00
Minggui Cao c3d60297f2 DM: use log macro/func to output log info
also add logs for some key entries.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-05 19:13:07 +08:00
Minggui Cao 4e289341ff DM: add logger params in launch script for NUC&UP2
add logger_setting params in launch_uos.sh for NUC & UP2;
then the logger system can work; by default console logger
is enabled.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-05 19:13:07 +08:00
Minggui Cao 1cd914f992 DM: add logger setting parser function
the logger setting can be input as acrn-dm params;
so need parse it to init logger system.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-05 19:13:07 +08:00
Minggui Cao 229d44a884 DM: add kmsg logger to sync with kernel log
kmsg logger used to output ACRN-DM log to /dev/kmsg,
it is easy to sync with kernel log.

it is better just output key info or error/failure
log to kmsg for kernel log size is limited.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-05 19:13:07 +08:00
Minggui Cao c3954cecbe DM: add log macro/func and basic data structure.
also set default logger as console and enabled.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-05 19:13:07 +08:00
Yuan Liu 38e8059ce9 dm: uart_core: fix uart dm cause interrupt storm issue
For Linux kernel, the UART driver will disable IER.THRE. But for Windows, it
will keep IER.THRE turn on then cause interrupt storm.

From pc16550d UART spec, INTR PIN description:

"Interrupt. This pin goes high whenever any one of the following interrupt types
has an active high condition and is enabled through the IER Receiver Error Flag;
Received Data Available timeout (FIFO Mode only); Transmitter Holding Register
Empty; and MODEM Status. The INTR signal is reset low upon the appropriate
interrupt service or a Master Reset operation."

And Interrupt Reset Control of Transmitter Holding Register Empty Interrupt
description:

"Reading the IIR Register (if source of interrupt) or Writing into
the Transmitter Holding Register"

The datasheet hasn't describe very clear if the THRE interrupt will be
re-generate after "Reading the IIR Register". We assume it will not do
that, so the THRE interrupt only generate when THR turn to empty.

This patch follows above assumption to resolve the interrupt storm cause WaaG
boot failed issue.

Tracked-On: #2713
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-01 10:52:14 +08:00
Sainath Grandhi 7a78e70eb3 acrn-dm: Pass vbdf and pbdf info to vm_reset_ptdev_intx_info
ACRN interepts vm_set/reset_ptdev_intx_info hypercalls to set
the SOS vdev properties to indicate it is assigned to UOS. Today,
upon vm_reset_ptdev_intx_info hypercall ACRN does not revert the SOS
vdev properties back to that of SOS, as vbdf and pbdf were not
part of the API. This would leave ACRN data structures in an incorrect
state

Tracked-On: #2700
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-29 17:04:02 +08:00
fuyongjie ae07844717 DM: virtio-gpio: close gpio line fd
When vm reset,the gpio line state is busy if we don't close the fd.

Tracked-On: #3028
Signed-off-by: fuyongjie <fuyongjie@vip.qq.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-29 09:20:38 +08:00
Yin Fengwei 8055039545 Makefile: add gcc option to workaround build issue with latest gcc
With latest gcc, there are build error with current ACRN code.
Fixing could involve many code changes. We use gcc option to
remove build error as temperary workaround. And will fix the
build error one by one.

Tracked-On: #3010
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-25 21:28:32 +08:00
fuyongjie 2387010fdd DM: virtio-gpio: fix falling or rising irq can't work
When UOS set failling irq type, gpio BE will only request GPIOEVENT_REQUEST_FAILLING_EDGE
event from native gpio driver which will cause the last_level value is always 0.
So last_level can't be used to check whether interrupt should be injected or not.
It is the same for rising irq type.

v2: refine commit message.

Tracked-On: #3010
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Signed-off-by: fuyongjie <fuyongjie@neusoft.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-25 15:28:13 +08:00
Zhao Yakui 7ef9498fe0 acrn/dm: gvt returns negative errno to terminate the initialization
When the "i915.enable_gvt=0" is added for SOS kernel boot args, ACRN-DM will
fail in course of gvt initialization and errno is returned directly.
As the errno defined in linux/errno.h is positive, it will continue
the unexpected initialization in ACRN-DM and then the segment fault is
triggered.
So negative errno is returned in order to terminate the initialization.

Tracked-On: #2584
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-25 15:11:10 +08:00
Liu Yuan 763d218302 DM: virtio-gpio: fix array overflow issue
explicitly initialize the cmd_cap string array.

Tracked-On: #3001
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-23 15:12:39 +08:00
Jian Jun Chen f3f870b7be dm: uart: use mevent_add only when it is a tty
When acrn-dm is started by acrnd as a background process, STDIN is
redirected to journal. In this case mevent_add cannot be called on
the fd of STDIN.

Tracked-On: #2998
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-23 14:57:56 +08:00
Yonghua Huang 3060956582 dm: fix possible null pointer dereference in pci_gvt_deinit
will access null pointer if 'gvt' is null.

Tracked-On: #1479
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
2019-04-23 13:44:05 +08:00
Peter Fang 82fa9946e0 dm: safely access MMIO hint in MMIO emulation
mmio_hint in mem.c can potentially be accessed concurrently in
emulate_mem() because it only holds a read lock. Use a local variable to
make sure the same entry address is used throughout the function. Since
it only serves as a hint, it's okay if the function does not use the
most up-to-date version of mmio_hint, as long as mmio_hint is accessed
atomically.

Explicitly enforce natural alignment on mmio_hint to guarantee atomic
accesses on x86 and increase code portability, even though compilers
most likely always do it.

Entries in the RB tree are only removed in unregister_mem_int() while
holding a write lock, so accessing mmio_hint while holding a read lock
is safe.

Tracked-On: #2902
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-22 15:18:21 +08:00
Peter Fang 4c38ff00c6 dm: completely remove enable_bar()/disable_bar() functions
Following up on d648df766c, surgically
remove all the functions related to enable_bar()/disable_bar() that got
introduced in 8787b65fde.

Tracked-On: #2902
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-22 15:18:21 +08:00
Peter Fang a718fbe860 dm: pci: change return type to bool
Change return type to bool when returning int is not necessary.

Tracked-On: #2902
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-22 15:18:21 +08:00
Yonghua Huang 0ae5ef3a29 dm: add IOCTL command to get platform information
Add interface to get hardware information and
  configurations for current platform.

Tracked-On: #2538
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-18 15:02:48 +08:00
Wei Liu 948d58fb9c acrn-dm: enable debug option for acrn-dm
enable acrn-dm debug option via RELEASE=0(by default)

Tracked-On: #2939
Reviewed-by: Minggui Cao <minggui.cao@intel.com>
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-16 15:24:25 +08:00
Yin Fengwei 2e5a6e28b9 watchdog: map the watchdog reset to warm reset
Per debugging requirement, map the watchdog reset to warm reset.
So the ramconsole could be used to capture the kernel log of UOS
before watchdog is hit.

Tracked-On: #2471
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-16 15:24:25 +08:00
Jian Jun Chen 2f4e320730 dm: virtio-input: adapt Windows virtio-input driver
Update PCIR_SUBDEV_0 and PCIR_REVID in PCI configuration space to adapt
windows virtio-input driver. Otherwise virtio-input driver on Windows
will not be loaded correctly.

Tracked-On: #2962
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Jian Jun Chen 8115857956 dm: pci: unregister bars which are still enabled in pci_emul_free_bars
Guest OS for example Windows will disable bars before shutdown. Bars
are unregistered when they are disabled. Trying to unregister a bar
which has been unregistered causes a assertion. In pci_emul_free_bars
only those enabled bars should be unregistered.

Tracked-On: #2962
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Jian Jun Chen fd389cb15c dm: disable ACPI PM timer
ACPI PM timer is disabled in FADT since there is no pm timer emulation
in device model now.

Tracked-On: #2962
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Yu Wang 98dfc6f267 dm: virtio-block: extend the max iov number of virtio block
It is found that windows will issue blkio operation with amount of
sectors in one request. This patch extends the max iov number of
virtio block to 256.

Tracked-On: #2962
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Liu Shuo A fa7f6c2c83 dm: fix deadlock between emulate_mem and un/register_mem
There is a deadlock when emulate_mem is called on the memory region
of PCI extended configuration space. The call trace is something like:
    emulate_mem
 -> pci_emul_ecfg_handler
 -> pci_cfgrw
 -> pci_emul_cmdsts_write
 -> unregister_bar/register_bar
 -> modify_bar_registration
 -> unregister_mem/register_mem

mmio_rwlock is hold in emulate_mem when calling unregister_mem/
register_mem which is trying to acquire mmio_rwlock again, and deadlock
happened.

It is possible that bar address is changed just between a on-going
MMIO access which can bring a race condition in theroy. Guest needs to
take care of the serial operation between bar addess update and MMIO
access of that bar.

Tracked-On: #2962
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Signed-off-by: Liu Shuo A <shuo.a.liu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Liu Shuo A d648df766c dm: register_bar/unregister_bar when bar enable/disable
Sometimes guest OS writes PCIR_COMMAND register to disable the device,
then update the bar address followed by a write to PCIR_COMMAND register
to enable the device again. In this case unregister_bar/register_bar
should be called otherwise the IO/MMIO regions monitored by device model
will not be updated accordingly.

Tracked-On: #2962
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Signed-off-by: Liu Shuo A <shuo.a.liu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Yu Wang b838e9b720 dm: pm: mask the higher bits of parameter of smi_cmd handler
Windows will set 0x262a0 for smi cmd pio, need to mask the higher bits
due to smi command is 8 bits register. Otherwise, it cause the
ACPI_ENABLE case can't be matched, and windows expecting the SCI_EN of
PM1_CONTROL be set after switch to ACPI mode. Finally, cause windows
trigger panic.

Tracked-On: #2962
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Jian Jun Chen 15966f94b5 dm: uart: add uart over tcp support
This patch adds the support of inet socket as the backend of uart
emulation. Data written by guest uart is transferred to a socket and
data from socket is forwarded to guest uart. This enables something
called "Uart Over TCP" which is useful in some case such as WinDbg
connection over uart. The command line syntax is as follows:
-l comX,tcp:port_number

Tracked-On: #2962
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-16 15:03:04 +08:00
Yonghua Huang 6ac9e15a2b dm: fix possible memory leak in 'load_elf32()'
Dynamic memory stored in 'elf32_phdr' allocated
through 'calloc' be lost.

the patch port from apl_sdc_stable branch.

Tracked-On: #2705
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-04-15 17:33:42 +08:00
Jiang,Mao e50c0c88fb tools: acrn-manager: fix the possibility of creating directory at will by no permission process
There are several duplicate definitions for check_dir, it can check or create directory at will. However, only acrnd and dm monitor can create the directory. This commit fixs the possibility of creating directory at will by no permission process, which adds a param flags to conctrl if it should create the directory. By the way, this commit collates related MACRO into the same file , deletes the duplicate definitions in another files and fixs some format issues.

Tracked-On: #2886
Signed-off-by: Mao Jiang <maox.jiang@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2019-04-15 17:01:03 +08:00
Victor Sun 6071234337 HV: use term of UUID
The code mixed the usage on term of UUID and GUID, now use UUID to make
code more consistent, also will use lowercase (i.e. uuid) in variable name
definition.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-12 13:45:32 +08:00
Xiaoguang Wu 122685b7b9 DM USB: xHCI: refine the failure process logic of control transfer
The old logic to process control transfer failure only include two cases:
1 Short packet
2 Stall.
This patch includes all possible failures reported by Libusb and does
related emulation for UOS

Tracked-On: #2918
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-11 20:05:20 +08:00
Yuan Liu 8796ded21b DM USB: fix SWWDT_UNHANDLED issue
add a delay for usb in launch_uos.sh

Tracked-On: #2922
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-11 13:21:30 +08:00
Xiaoguang Wu 8bd7b9beae DM USB: xHCI: fix an logic error during USB reset
Should not set hci_address to zero during USB reset.

Tracked-On: #2922
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-11 13:21:30 +08:00
Yuan Liu b570755fd0 Domain id and name added to launch_uos.sh
For multiple guest os and particular audio features support domain id
and name is required.

Tracked-On: #2924
reviewed-by: Yu Wang <yu1.wang@intel.com>
reviewed-by: Yakui zhao <yakui.zhao@intel.com>
reviewed-by: Binbin Wu <binbin.wu@intel.com>
Signed-off-by: Marcin Pietraszko <marcin.pietraszko@intel.com>
2019-04-11 11:18:57 +08:00
Yuan Liu 6eaadc34c0 dm: passthru: support SD hotplug
Add SDC ACPI device in dsdt, and assign GPIO 0 to SDC for SD card
detection.

Currently, the SD card hotplug function needs to insert SD card when
system boot, otherwise, it does not work. Since it needs P2SB virtualization
to set SD card presence state, and P2SB does not support user space interfaces
so this is an known issue.

Tracked-On: #2512
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-11 10:10:15 +08:00
Xiaoguang Wu 784bfa28ae DM USB: xHCI: fix an issue during BULK transfer
When LINK type TRB are received among multiple BULK TRBs, the copying
logic in DM will miss one or more TRBs. This patch is used to fix it.

Tracked-On: #2926
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-11 10:08:45 +08:00
Xiaoguang Wu 63743d8b9b DM USB: xHCI: WA for an isochronous crash issue
The current xHCI mediator doesn't well support disable endpoint command.
This patch is one workaround for disable endpoint command to avoid
xHCI mediator to continue handle already dropped data.

Tracked-On: #2927
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-10 17:54:34 +08:00
Jie Deng 00dd26b081 dm: remove "acrn_" prefix from tap name
Some projects based on ACRN don't want tap name to contain "acrn_"
prefix. This patch removes that prefix.

Tracked-On: #2509
Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-04-09 10:59:45 +08:00
Yuan Liu 4a6bc369ad DM: virtio-gpio: implement GPIO operations via accessing PIO
GPIO set/get value can be operated by accessing PIO space and the PIO
register definition for GPIO is in gpio_dm.h, frontend driver or ACPI
control methods can operate GPIO based on it.

GPIO mediator also defines ACPI control methods to support GPIO
operations, GPIO consumers can invoke PIO_GPIO_SET_VALUE/PIO_GPIO_GET_VALUE
in their own DSDT to set/get one GPIO value via ACPI control method.

v2: 1) Fix code style.
    2) Use virtio configuration space callbacks to implement GPIO PIO operations
       that replace pci_gpio_read/pci_gpio_write with virtio_cfgread/virtio_cfgwrite.
    3) Return 0xFFFFFFFF as invalid result of PIO reading instead 0.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-08 10:51:49 +08:00
Conghui Chen e8dda1e914 DM USB: fix memory leak during reboot
1. free memory during pci_xhci_dev_destroy.
2. add libusb_free_device_list to free the list of devices previously
discovered using libusb_get_device_list().
3. fix possible memory corruption.

Tracked-On: #2892
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-04 18:35:02 +08:00
Kaige Fu c4ec7ac358 DM: Keep consistency between HV and DM about PM1A_CNT_ADDR
To keep consistency between HV and DM about PM1A_CNT_ADDR,
it is better to replace the PM1A_CNT related MACROs used in DM
with VIRTUAL_PM1A_CNT related MACROs in acrn_common.h.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2019-04-04 17:51:15 +08:00
Conghui Chen ede5987c11 dm: storage: add read-only feature for virtio-blk
Add VIRTIO_BLK_F_RO feature bit for virtio-blk.

Tracked-On: #2887
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-04 12:27:38 +08:00
Kaige Fu 469ce711c5 DM: Add new parameter --rtvm for soft/hard real-time guest
This patch add one new parameter --rtvm to indicate if the guest is a RTVM or not.
For RTVM, it may be not interference by SOS.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-04 00:27:55 +08:00
Peter Fang f412d52546 dm: protect pthread_cond_wait() against spurious wakeups
Users of pthread_cond_wait() should take care of spurious wakeups and it
is usually used in conjunction with a predicate. Not doing so can result
in unintended behavior. For example:

virtio_net_tx_thread():
  entry -> pthread_cond_wait() -> spurious wakeup ->
  vq_clear_used_ring_flags() -> segfault (vq->used uninitialized)

tpm_crb_request_deliver():
  entry -> pthread_cond_wait() -> spurious wakeup ->
  swtpm_handle_request() called needlessly

virtio_rnd_get_entropy():
  entry -> pthread_cond_wait() -> spurious wakeup ->
  no avail ring processing ->
  virtio_rnd_notify() skips pthread_cond_signal() due to
  rnd->in_progress ->
  vq_endchains() called needlessly ->
  wait in pthread_cond_wait() indefinitely

Fix these uses of pthread_cond_wait() by using predicates.

The only use case without a clear predicate is the tx thread in
virtio-mei, because it works with two-dimensional linked lists.

v1 -> v2:
- fix bugs and comments
- reduce code redundancy

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang e9261121b3 dm: mei: code cleanup
- explicitly initialize the connections list
- use a do-while loop for vmei_proc_tx() since the first call must
  always succeed
- make sure active_clients is initialized before creating the tx thread

v1 -> v2:
- split the cleanup commit into two parts

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang bb54a2c7c6 dm: mei: use LIST_FOREACH() to traverse lists
Remove the uses of LIST_FIRST() and LIST_NEXT() plus an extra pointer.

Also, call LIST_INIT() in vmei_me_client_destroy_host_clients() before
releasing the mutex.

v1 -> v2:
- split the cleanup commit into two parts

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang 18aebc0196 dm: safely use pthread_cond_broadcast()
Use pthread_cond_broadcast() while holding the mutex to guarantee the
signaling of its condition variable.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang fa375a2aa1 dm: virtio: ensure interrupt delivery in virtio-blk
virtio-blk never sets used_all_avail when calling vq_endchains(), which
may become problematic if VIRTIO_F_NOTIFY_ON_EMPTY is enabled.

Provide vq_endchains() with that info to ensure the delivery of an
interrupt when the avail ring is drained in the case of
VIRTIO_F_NOTIFY_ON_EMPTY.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang d38afa6f48 dm: virtio: make sure VQ_ALLOC is set after initialization
Make sure VQ_ALLOC is visible only after vq is completely initialized.

This ensures vq_ring_ready() is reliable when it returns true.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang 6be9f15aa6 dm: virtio: change return type to bool
Change return type to bool when returning int is not necessary.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang 296c974dc0 OVMF release v0.8
- Remove QemuFwCfg/QemuFwCfgS3Lib
- Use ACRN E820 map to query system memory size
- Support 64-bit PCI host aperture via ACRN E820
- Remove debug code in release build
- Take out unnecessary OVMF drivers
- Revert "Enable MP support"
- Use CPUID 0x40000010 to determine tsc frequency

Tracked-On: #2868
Signed-off-by: Peter Fang <peter.fang@intel.com>
2019-04-01 12:39:42 +08:00
Kaige Fu efad496352 DM: Add -A to support S5 of hard rt vm
This patch add '-A' to support S5 of hard rt vm.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-03-29 16:17:44 +08:00
Kaige Fu 2e4d7eb527 DM: Add new flag GUEST_FLAG_RT for RTVM
This flag indicates that if the vm is RTVM.
And if a vm has GUEST_FLAG_LAPIC_PASSTHROUGH flag set,
we must set the GUEST_FLAG_RT at the same time.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-03-29 16:17:44 +08:00
Long Liu 9f2342220d ACRN: dm: Enable mount namespace for container.
The patch adds mount namespace for the container. Without the patch
when we destroy the container, there still have mountinfo for the
container. This is one workaroud for runC bug. If the mount namespace
is disabled, when try to mount host "/" to container "/", there will
cause the issue. Detail discussion as following link.
"https://groups.google.com/a/opencontainers.org/forum/#!searchin/
dev/mount$20namespace%7Csort:date/dev/p10bq-kXODk/obkqBRdxCQAJ"

After enable mount namespace, some small performance imapcts for
specific mediator, likes USB. Will keep monitor runc community,
and revert this patch once related runc patches get integrated.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-29 11:46:19 +08:00
Long Liu dde326ec6a Acrn: dm: Add new start parameter in sample args
The patch adds "-C" parameter in sample launch_uos.sh file to enable
launch Device-Model in runC container. The argments will be linked to
SOS /usr/share/acrn/add/vm1.args, and acrnd will use the it as default
start argument.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-29 11:46:19 +08:00
yuhong.tao@intel.com 8109c2e94c DM: restrict vmname size to 32 bytes
Length of vmname is restricted to MAX_VM_OS_NAME_LEN. Keep it
coincide with VM name array size in vm_config.

Tracked-On: #2851
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-26 21:23:16 +08:00
yuhong.tao@intel.com c55308bd3d DM: use soft link of acrn_common.h in HV
devicemodel/include/public/acrn_common.h should be identical with
hypervisor/include/public/acrn_common.h, so we can use a soft link
to hypervisor's acrn_common.h for devicemodel.

Tracked-On: #2851
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-03-26 21:23:16 +08:00
Jian Jun Chen 06761102a8 dm: remove smbios
smbios table is not required so remove it.

Tracked-On: #2577
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-26 00:21:52 -07:00
Peter Fang 20164799cb dm: leave a gap for 32-bit PCI hole in E820 map
Guest OS (e.g. Linux) may rely on a gap in E820 map in the 32-bit memory
space to determine the MMIO space for its PCI devices. Leave this gap
when building E820 map to keep the guest's PCI subsystem working.

After commit 7752d5cfe3d11ca0bb9c673ec38bd78ba6578f8e, Linux kernel no
longer requires the MMCONFIG region to be reserved in the E820 map.
Nonetheless, keep it in the reserved region to be on the safe side.

Tracked-On: #2843
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-25 13:49:48 +08:00
Yuan Liu 12d977284a DM: virtio-gpio: export GPIO ACPI device
Add dsdt for virtio-gpio device.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 20:12:33 -07:00
Yuan Liu 014e611b14 DM: virtio-gpio: add IRQ statistics
print each IRQ descriptor interrupts number and all of IRQ descriptors
interrupts when UOS requests or releases a GPIO IRQ.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 20:12:33 -07:00
Yuan Liu 83a98acb1b DM: virtio-gpio: support reading value from IRQ descriptor
Support reading GPIO value when the GPIO switches to IRQ mode.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 20:12:33 -07:00
Yuan Liu d34b3ebdd0 DM: virtio-gpio: emulate GPIO IRQ controller
GPIO IRQ controller emulation is used to handle level trigger and
edge trigger interrupts. Use GPIO IRQ virtqueue to handle IRQ chip
operations and GPIO event virtqueue to indicate IRQ source to UOS.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 20:12:33 -07:00
Yuan Liu 92a0a399b7 DM: virtio-gpio: GPIO IRQ initialization.
add the GPIO IRQ definitions, and implement the GPIO IRQ
initialization and deinitialization.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 20:12:33 -07:00
Yuan Liu 9480af8d32 DM: virtio-gpio: setup two virqueues for gpio irq
There are two virtqueues for irq, one for handling the operations of
front-end irq controller and the other for triggering the interrupt.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 20:12:33 -07:00
Peter Fang 071ce15ed4 dm: build E820 map for OVMF
OVMF requires a more descriptive mechanism than RTC CMOS to retrieve
ACRN's memory layout, so we now pass the E820 map to it, starting at
0xEF000 (ROM area).

ACRN currently uses [4GB, 5GB) as its 64-bit PCI host aperture. This is
inconsistent with OVMF's assumption of its platform's memory layout,
because it derives the size of high memory from RTC CMOS, which is
incapable of describing the 64-bit PCI hole.

By default, OVMF uses RTC CMOS 0x5b/0x5c/0x5d to determine the size of
high memory. This value only tells OVMF how much memory is above 4GB,
but not the platform's memory layout above 4GB.

Using RTC CMOS works for QEMU, because QEMU places its 64-bit PCI host
aperture above its highmem. Therefore, OVMF can always assume highmem is
located at [4GB, 4GB + highmem), which is not where ACRN's highmem is
located. For example, if we have 1GB of usable memory above 4GB, ACRN
will place it at [5GB, 6GB).

This change allows OVMF to correctly identify the guest's memory layout.
It will consider any reserved region above 4GB as 64-bit PCI host
aperture.

MP table, SMBIOS and ACPI tables are all located above 0xF0000 so it is
guaranteed that there is no overlap. There can only be a maximum of 128
E820 entries.

v1 -> v2:
- provide more explanation to this commit
- add signature before E820 map for OVMF backward compatibility

Tracked-On: #2792
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-21 10:28:17 +08:00
Peter Fang 4dd1331072 dm: remove empty UOS E820 entries
While building the E820 map for UOS, [lowmem, lowmem_limit) and [5GB,
highmem) can be empty. Remove the empty entries if they appear.

Tracked-On: #2792
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-21 10:28:17 +08:00
Peter Fang 643513f3d4 dm: update UOS default E820 map
- fix comments
- update the first RAM region to [0, 0xA0000) because [0xA0000, 1MB) is
  designated as video memory and ROM area
- use 2GB as lowmem_limit

Tracked-On: #2792
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-21 10:28:17 +08:00
Peter Fang 263b486a09 dm: pci: add MMIO fallback handler for 64-bit PCI hole
Add the PCI MMIO fallback handler to the 64-bit PCI host aperture, so
that the guest won't inadvertently crash acrn-dm due to unhandled MMIO.

Tracked-On: #2792
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-21 10:28:17 +08:00
Peter Fang 82e42cfa2a dm: clean up mem.c
- use strncmp() instead of comparing string pointers to make no
  assumptions about the toolchain's literal pool
- re-shuffle the functions so they're consistent with mem.h
- make non-public functions static
- increase code re-use

Tracked-On: #2792
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-21 10:28:17 +08:00
Peter Fang 890d40226b dm: remove GUEST_CFG_OFFSET
Per commit dbd9ab07e1, GUEST_CFG_OFFSET is
no longer needed.

Tracked-On: #2792
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-21 10:28:17 +08:00
Binbin Wu 7669a76f95 dm: passthru: pass pbdf when reset msi/msix interrupt
Physcial bdf is needed in hypervisor to find the right pci dev.

Tracked-On: #2788
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-03-15 20:57:39 +08:00
Kaige Fu b147c5c649 DM: Mark thre_int_pending as true when THR is empty
This patch marks thre_int_pending as true when THR is empty.

Tracked-On: #2713
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-03-14 16:37:41 +08:00
Minggui Cao 5397200118 DM: fix memory leak
1. free memory allocated by strdup in blockif_open
2. free msix.table when its pci device deinit

Tracked-On: #2704
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-14 15:17:30 +08:00
Zhao Yakui 93386d3c70 ACRN/DM: Destroy the created pci_device iterator to fix memory leak in passthru_init
Now it will call the below function to create the corresponding pci_device_iterator
in passthrough device initialization. But it is not released in time.
So it needs to be released to fix the memory leak issue.

Tracked-On: #2762
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-14 12:55:49 +08:00
Zhao Yakui 31cb4721e1 acrn/dm: Remove the memory leak in gvt mediator
Otherwise it causes the memory leak.

V1->V2: Fix the leak of pi->arg as gvt structure also needs to be released.

Tracked-On: #2762
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-14 12:55:49 +08:00
Tw 065e16d32e Makefile: make UP2 sample directory name consistent with board name
It makes more sense by aligning directory name with board name.

Tracked-On: #2760
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-03-14 11:57:05 +08:00
wenlingz 20249380d3 audio-mediator: load updated audio kernel modules
Audio kernel has updated name and add two new kernel modules from SOS
28100

Tracked-On: #2744
Signed-off-by: wenlingz <wenling.zhang@intel.com>
2019-03-14 11:08:44 +08:00
Binbin Wu 4d0419ed71 dm: passthru: fix potentail mem leaks
Fix potential memory leakage in some error case handling.

Tracked-On: #2704
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-03-14 09:08:21 +08:00
Conghui Chen 6f482b8856 dm: virtio: add memory barrier before notify FE
Without memory barrier, the change of used ring index could not
immediately detected by FE, this would bring some problems.

For virtio-blk FE driver, when it receives an interrupt, and confirms the
used ring index has changed, it will first set ring flags with
VRING_AVAIL_F_NO_INTERRUPT, then get buffer from virtqueue, after
process this request, it will mask VRING_AVAIL_F_NO_INTERRUPT, and get
used ring index again before return. If used ring changes, it will
process it. At the same time, BE will read this flags before each notify,
if VRING_AVAIL_F_NO_INTERRUPT was set, BE will not inject interrupt.

Without memory barrier, before FE mask VRING_AVAIL_F_NO_INTERRUPT, BE
has finished notify without interrupt, then FE mask
VRING_AVAIL_F_NO_INTERRUPT, and get used ring index but failed (index
has changed from BE side). FE will return from interrupt handler
function, and wait for next interrupt which was not injected by BE. Thus,
this will cause kernel hung.

Tracked-On: #2732
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2019-03-12 14:15:10 +08:00
Conghui Chen 7ab6e7ea03 dm: usb: fix possible memory leak
fix possible memory leak for usb.

Tracked-On: #2704
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-03-12 13:47:57 +08:00
Kaige Fu 694fca9c06 DM: Add sample script to launch zephyr as guest
This patch add one sample script to launch zephyr as guest.

Tracked-On: #2713
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
2019-03-12 09:59:06 +08:00
Jie Deng 18ba75248f dm: virtio-net: fix memory leak
Dynamic memory stored in 'net' allocated through function 'calloc'
should be freed correspondingly when return fail.

Tracked-On: #2704
Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-03-11 17:40:31 +08:00
Yuan Liu f6a989b7be dm: use power button acpi device to find its input event
check the power button acpi driver firstly, then find input event
corresponding to the power button.

Tracked-On: #2695
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-07 20:23:48 +08:00
Binbin Wu f572d1ecdd [RevertMe] dm: pci: restore workaround when alloc pci mem64 bar
There was a workaround in DM that allocates PCI 64bit mem bar in 32bit mem space
if the bar size is within 32MB.

After the workaround being removed, there is an issue to enter fastboot
mode for inappropriate handling of 64bit mem bar in guest driver.
The patch bring the workaround back, and skip the workaround when the guest
is booted by OVMF.

Revert the patch after the guest fixs the issue of handling 64bit mem bar in
fastboot mode.

Tracked-On: #2677
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-05 15:14:24 +08:00
Long Liu 8a324060c1 ACRN: dm: Fix luanch UOS script "-d" parameter fail issue
Fix launch UOS script "-d" parameter fail issue

Tracked-On: #2659
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-03-01 20:23:46 +08:00
Peter Fang 061189981d OVMF release v0.7
- Change system timer from 8254 to HPET
- Fix UEFI console UI issue
- Enable MP support
- Install ACRN DM's ACPI tables
- Remove Bhyve ACPI tables
- fix backspace issue in UEFI shell
- clear CD bit in SEC
- Revert "workaround: disable CR0.CD"
- workaround: disable CR0.CD
- boots Clear Linux (1 vcpu)

Tracked-On: #2662
Signed-off-by: Peter Fang <peter.fang@intel.com>
2019-03-01 20:23:22 +08:00
Yuan Liu 35dfadc98e dm: check SCI_EN bit of pm1_control before trigger SCI
Followed ACPI spec 4.8.2.5, if SCI_EN is set, the interrupt will be
routed to SCI interrupt logic. If SCI_EN is not set, the interrupt
will be routed to SMI interrupt logic.

ACRN does not support SMI for now, so check SCI_EN before trigger
SCI.

Tracked-On: #2560
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-01 08:09:42 +08:00
Yuan Liu 566e8824da dm: power button emulation by acrnctl command.
when UOS is running, "acrnctl suspend vm" and "acrnctl stop vm" commands are
able to trigger a SCI interrupt, then UOS enters sleep or shutdown according
to the default behavior of the power button. The default behavior is based on
UOS power button setting.

Tracked-On: #2560
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-01 08:09:42 +08:00
Jian Jun Chen 29b1ebcd43 dm: add support of high MMIO mapping
1G PCI hole is added just after 4G address which is used as the
PCI high MMIO address space. Guest high memory is mapped from 5G
address for both EPT and device model user space address. Guest
e820 table and API vm_map_gpa are updated accordingly.

Tracked-On: #2577
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 18:33:11 +08:00
Liu Shuo A 32925c10bd dm: allocate 64bit MMIO above 4G strictly to pass OVMF check
Remove the >32MB limitation for 64bits mmio hole allocation, ACRN
hasn't met such buggy devices for this limitation. Besides, OVMF
has one bug which requires 64bits BAR must allocate from 4G+ address,
otherwise trigger assert. This patch can workaround it.

Tracked-On: #2577
Signed-off-by: Liu Shuo A <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 18:33:11 +08:00
Shuo Liu aed75145c1 dm: Limit 64 bits PCI BAR region address space
Limit 64 bits PCI BAR space from 0x100000000UL ~ 0x140000000UL,
as HV now only support 0x400000000UL+0x80000000 as top of guest memory
address. EPT table size is static allocated.

Tracked-On: #2577
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 18:33:11 +08:00
Yuan Liu 7628e790e7 DM: virtio-gpio: use virtio_base as the first member of virtio_gpio
For virtio-based device, it needs to use virtio_base as the first member
otherwise, virtio_linkup will fail.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 17:19:36 +08:00
Tw 33ecdd7389 Makefile: undefine _FORTIFY_SOURCE prior using it
Currently, we are enforcing the _FORTIFY_SOURCE=2 without any
previous detection if the macro has been already defined, e.g.
by environment, or is just enabled by compiler by default on
some distributions (e.g. Gentoo).

This could result in the error like this:
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>: note: this is the location of the previous definition

Tracked-On: #2344
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-02-28 11:56:45 +08:00
Long Liu 6865210493 ACRN: dm: Modify runC default rootfs directory
The patch changes runC container's default rootfs directory. In the patch
change the rootfs to runC bundle's parent directory. Because in ACRN we map
SOS rootfs to container so the rootfs is an empty directory, after move it to
parent directory all the container can share the same rootfs.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
2019-02-25 20:24:22 +08:00
Long Liu 55cb777000 ACRN: dm: Add new capabilities for runC container
The patch adds more Linux capabilities for runC container. In ACRN runC
we will map native root directory to the container, when we launch UOS from
container it need more Linux capabilities to operate dev node. So add the
capabilities in runC configuration file.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
2019-02-25 20:24:22 +08:00
Long Liu 5690b7626f ACRN: dm: Change runC container's start arguments
Change the default runC container start application to sh which will be
modified by launch_uos.sh during UOS boot. And the replacement is the
parameter set by "acrnctl add" command.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
2019-02-25 20:24:22 +08:00
Long Liu 6e919d2afe ACRN: dm: Add launch container method in script
This patch implements acrn-dm QoS. When the script be launched with "-C"
parameter, the acrn-dm will be executed in container for isolating the
resouce of service OS.

The QoS parameter is described in
/usr/share/acrn/samples/apl-mrb/runC.json, users can modify it following
their performance requirements.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
2019-02-25 20:24:22 +08:00
Huang Yang 2f7ed65f90 DM: Attestation Keybox support in SOS DM
Retrieve the encrypted attestation Keybox from CSE
and provision it to RPMB storage.

Tracked-On: #2604
Signed-off-by: Huang Yang <yang.huang@intel.com>
Signed-off-by: Wei Xinghai <xinghaix.wei@intel.com>
Signed-off-by: Chen Gang <gang.g.chen@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2019-02-25 16:40:25 +08:00
Yuan Liu 780f520fc6 DM: virtio-gpio: return a valid length for GPIO request
When the backend completes a GPIO request, it returns a valid length
to ensure that response correct.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-25 14:17:05 +08:00
Yuan Liu 21ae3e7451 DM: virtio-gpio: add print log
if the gpio debug is enabled, print gpio mapping information about
virtual gpio and native gpio, also print virtio-gpio data, which shows
the gpio operations flow.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-21 14:11:52 +08:00
Yuan Liu 6b0643b535 DM: virtio-gpio: implementation of gpio opearations
Implement gpio set/get value, direction input/output and set config operations.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-21 14:11:52 +08:00
Yuan Liu 77e17b5dff DM: virtio-gpio: gpio initialization.
Add gpio initializaiton and gpio usage implementation

gpio usage:
-s <slot>,virtio-gpio,<gpio resources>

<gpio resources format>
<@chip_name{offset|name[=vname]:offset|name[=vname]:...}
[@chip_name{offset|name[=vname]:offset|name[=vname]:...}]
[@chip_name{offset|name[=vname]:offset|name[=vname]:...}]
...>

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-21 14:11:52 +08:00
Yuan Liu 57029315d7 DM: virtio-gpio: virtio framework implementation.
virtio framework implementation for virtio-based gpio virtualization.
virtio-based gpio uses one virtqueue to implement gpio operaions and
frontend gpio chip base and number are provided by virtio config.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-21 14:11:52 +08:00
Yuan Liu 8e8ed07dd7 dm: implement power button for power managerment
Listen to power button state via /dev/input/event0. When the power
button is pressed, then set PWRBTN_STS bit. If PWRBTN_EN is set, the
sci interrupt is triggered.

For suspend or shutdown of UOS by power button, needs UOS to configure
the default behavior of the power button.

Tracked-On: #2560
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-21 11:48:02 +08:00
Minggui Cao 07656a9cc6 DM: modify acpi for IASL to support ACPI6.3
patch is from Alex Du for IASL tool updated to support
ACPI 6.3 version.

Tracked-On: #2568
Signed-off-by: Alek Du <alek.du@intel.com>
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2019-02-20 20:05:32 +08:00
Vijay Dhanraj c2e741ad90 dm: Add socket backend support for virtio-console
Socket is not currently supported as backend for virtio-console.
Kata containers require socket backend for virtio-console in order to
communicate between the agent running in the VM and the proxy running
in the host. In order to support Kata with ACRN, this feature is required.

v1-->v2:
Prevent new accepts on an already established socket connection. This
removes the need for accepted_fd and accept_evp varibles introduced in
previous patch.

v2-->v3:
Fixed coding style and removed debug prints.

Tracked-On: #2448
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-02-14 10:16:44 +08:00
Min He 4b53ed677c script: remove enable_initial_modeset for UP2 platform
For UP2 releases, we don't need enable_initial_modeset, just as the NUC
platforms, so remove this parameter from the boot args.

Tracked-On: #2516
Signed-off-by: Min He <min.he@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
2019-02-13 12:52:24 +08:00
Peter Fang 24cf377d5d dm: vhpet: fix vHPET memory leak on device reset
Need to properly remove and free its MMIO entry during deinit.

Tracked-On: #2453
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-02-06 08:53:27 +08:00
Yuan Liu be946ca8e0 IOC mediator: dynamically enable dummy channels
The dummy channels can emulate cbc lifecycle, cbc signal and cbc raw
channel instead canbox, and the feature can be enabled by ioc command
line within wakeup reason bit 24.

Tracked-On: #2481
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-01 16:05:43 +08:00
Xiaoguang Wu 80dc0bce3e DM: ACPI: Avoiding hard code the ASL_COMPILER macro
The ASL_COMPILER macro is hard coded as /usr/sbin/iasl, it is
complained by some developers. This patch changes it to a
flexible way, by which the following make command lines are
supported:

make
make devicemodel
make ASL_COMPILER=/path/to/iasl
make ASL_COMPILER=/path/to/iasl devicemodel

Tracked-On: #2298
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-02-01 13:47:55 +08:00
Xie, nanlin 2a25f4e9fc Doc: Remove CL release number from GSG document
Signed-off-by: Xie, nanlin <nanlin.xie@intel.com>
2019-01-30 15:16:56 +08:00
Yan, Like 878c4e2ddc dm: add example script to launch vm for realtime scenarios
This example script launch a VM with lapic passthrough for realtime scenarios.

Tracked-On: #2351
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-28 19:47:33 +08:00
Yan, Like c873d60ae2 dm: add option "lapic_pt" to create VM for realtime scenarios
New option "--lapic_pt" added to create VM with local apic passthrough, for
realtime scenarios.
When the option is set, a VM is created with LAPIC_PASSTHROUGH.
The option is not set by default.

Tracked-On: #2351
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-28 19:47:33 +08:00
Yan, Like 8925da64d9 dm: adapt mptable generation for VM with lapic pt
- don't generate io apic entry for vm with lapic pt.

Tracked-On: #2351
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-28 19:47:33 +08:00
Ross Burton 5ba4afcffe Use $(MAKE) when recursing
Using 'make' directly means that the jobserver environment variables don't get
passed down, so sub-builds for example don't use -j.

This is documented as the wrong thing to do:
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html#MAKE-Variable

Use $(MAKE) instead, and compile times drastically improve:

  acrn-devicemodel    do_compile   -13.5s   -89.6%      15.0s -> 1.6s

Tracked-On: #2370
Signed-off-by: Ross Burton <ross.burton@intel.com>
2019-01-24 08:22:32 +08:00
Conghui Chen ca925f0dd4 dm: storage: change DISCARD to synchronous mode
For virtio-blk, when the backend is a regular file, the discard
and
is implemented by fallocate(), but this function will not wait for
the discard command handled by disk.
So, add fdatasync to make sure the DISCARD is executed
synchronously.

Tracked-On: #2395
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2019-01-23 12:56:47 +08:00
Peter Fang 4642269248 dm: vhpet: add vHPET support
vHPET is used as a source of system timer by UEFI (e.g. OVMF).

This provides an alternative to using vPIT, which OVMF assumes is always
connected to vPIC.

This is ported from Bhyve, with a few changes:

- move to user space, using acrn_timer
- enable timers only when necessary

Origin: FreeBSD
License: BSD-3-Clause
URL: https://svnweb.freebsd.org/
commit: 326257
Purpose: Adding vHPET support.
Maintained-by: External

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang 0343da8c70 dm: vhpet: add HPET-related header files
Add the necessary header files for vHPET.

Origin: FreeBSD
License: BSD-3-Clause
URL: https://svnweb.freebsd.org/
commit: 326257
Purpose: Adding vHPET support.
Maintained-by: External

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang 3fe4c3f2a8 dm: provide timer callback handlers the number of expirations
It is possible for multiple timeouts to occur in one mevent epoll
iteration. Providing the number of timer expirations to the timer
callback handlers can be useful. E.g., this could improve emulation of
timing-sensitive hardware components.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang 0f7535fdbe dm: add absolute timer mode
Allow specifying the initial expiration in absolute time.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang d1e1aa3077 dm: create mevent's pipe in non-blocking mode
It was designed to be used in non-blocking mode to prevent the mevent
thread from blocking itself indefinitely, but it was created in
blocking mode.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Victor Sun 49e6deaf26 HV: rename the term of vm0 to sos vm
Under sharing mode, VM0 is identical with SOS VM. But the coupling of
SOS VM and VM 0 is not friendly for partition mode.

This patch is a pure term change of vm0 to sos VM, it does not change
any code logic or senmantic.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Tw fe35dde421 Makefile: support SBL binary for E2E build
Currently, we support SBL on two different boards.
So build and install them all in E2E build.

Tracked-On: #2344
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-18 11:22:15 +08:00
Zhao Yakui 13c44f5661 acrn/dm: Check device file of /dev/acrn_hsm to determine the path of offline VCPU
For the upstream purpose the device file of /dev/acrn_vhm is renamed
to /dev/acrn_hsm. Correspondingly the path of offline CPU is also changed.
So the device file of /dev/acrn_hsm is checked to configure the path
of ooffline VCPU.

Tracked-On: projectacrn/acrn-hypervisor#2356
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2019-01-18 11:04:22 +08:00
Zhao Yakui ca32881666 acrn/dm: Add the check of acrn_vhm/acrn_hsm to open the VHM driver
Currently VHM driver is opened by using the device file of /dev/acrn_vhm.
But for the upstream purpose it is renamed to /dev/acrn_hsm.
So we need to check that the device file is acrn_vhm or acrn_hsm and then
open the VHM driver.

Tracked-On: projectacrn/acrn-hypervisor#2356
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2019-01-18 11:04:22 +08:00
wenlingz 34b4294334 Doc: Update GSG for v0.5 version and launch and acrn.conf sample script
modify sbl_up2 version and scripts
2019-01-16 16:28:26 +08:00
Feng Tang ed9b533747 DM: sos_bootargs: Add panic_print parameter to help debugging
Adding this parameter so that it could provide more info when
kernel panic happens. And this has almost no overhead as it only
uses several existing kernel APIs.

The 0x1f is a bitmask for type of info to be dumped, and it means
it will print task/memory/timer/lock/ftrace info when panic happens.

Tracked-On: #2330
Signed-off-by: Feng Tang <feng.tang@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-14 16:19:59 +08:00
Yuan Liu 62e058a001 DM: mei: solving the issue of closing the fd
The issue leads that the IOC mediator's fd is turned off
incorrectly, causing the IOC mediator to fail.

The root cause is because after closing fd is not set
to an invalid fd.

The issue can be reproduced by the S3 stress test.

Tracked-On: #2301
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-11 11:26:42 +08:00
Yuan Liu 1049053e2e IOC mediator: fix the issue of abnormally missing tx package
The issue will result in the loss of wakeup reason and signal
data, because the CBC header was not added when generating the
tx package.

Tracked-On: #2283
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-01-11 09:21:35 +08:00
Min He e3b33a9871 script: remove DP-x:d parameters for UP2 board
There's a DP port on UP2 board, so we cannot add video=DP-x:d paramter,
otherwise, DP monitors will not be able to be detected on UP2 boards.

Tracked-On: #2268
Signed-off-by: Min He <min.he@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-10 10:08:56 +08:00
Shuang Zheng 79f40a569b Update and complete `acrn-dm` parameters description
Update and complete `acrn-dm` parameters description in the user guide and HLD

Tracked-On: #2036
Signed-off-by: Shuang Zheng shuang.zheng@intel.com
2019-01-09 16:19:35 -08:00
Zhao Yakui d094a39a7f DM: Try to load audio mediator BE driver before starting UOS
Currently whether audio works in virtio mediator or pass-through mode can be determined
by checking the device file of vbs_k_audio

But before the completion of loading audio virtio-BE module, the device file of /dev/vbs_k_audio
doesn't exist. In such case in course of loading UOS, the incorrect work mode is selected
for audio device (passthru instead of mediator). This is incorrect

Tracked-On: projectacrn/acrn-hypervisor#2247
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Alek Du <alek.du@intel.com>
2019-01-09 19:20:10 +08:00
Tw d2b03e8c33 dm:script: remove ioc related stuff from uos on UP2
UP2 don't have ioc, there is no need to simulate it.

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-08 11:26:27 +08:00
Tianhua Sun 01c8f546e0 DM: xHCI: array bound checking before it is used
Array index of "vbdp_devs" may be out of bounds if
"i >= XHCI_MAX_VIRT_PORTS", so index checking is necessary.

Tracked-On: #1252
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-01-03 22:42:40 +08:00
Shuang Zheng 04d9f52f68 update acrn-dm comment, remove the series of dot
Tracked-On: #2036
Signed-off-by: Shuang Zheng shuang.zheng@intel.com
2019-01-02 13:19:31 +08:00
Peter Fang 40f6a9fdff dm: allow PM1_RTC_EN to be written to PM1A
Clear Linux complains about not being able to write the bit to PM1A:

ACPI Error: Could not enable RealTimeClock event (20180531/evxfevnt-184)

Tracked-On: #2176
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2018-12-29 10:33:32 +08:00
Peter Fang 57c661c48d dm: vrtc: add RTC to ACPI DSDT
Clear Linux complains about not finding RTC as a PNP device:

platform rtc_cmos: registered platform RTC device (no PNP device found)

This is a port of Bhyve vRTC's user-space logic.

Tracked-On: #2176
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2018-12-29 10:33:32 +08:00
Binbin Wu 59e2de4805 dm: acpi: add PSDS table in ACPI table
Expose a new ACPI table PSDS to UOS.
This PSDS table show the security capability of the VM.
Only enable this table in UOS when PSDS presented in SOS.

Tracked-On: #888
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-28 22:11:09 +08:00
Tw 90fd5d5894 script: fix launch_uos script issue due to unseen character
Tracked-On: #1995
Space is tampered with unseen characters.
Reviewed-by: Binbin Wu <binbin.wu@intel.com>

Signed-off-by: Tw <wei.tan@intel.com>
2018-12-28 14:54:38 +08:00
Yin Fengwei 329ea42d73 dm: fix the memory leak in virtio mei
The possible memory leak was introduced by commit
7fce2462a0

If mevent add fails in virtio mei, the resource allocated doesn't
be released. This patch fix this memory leak issue.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-27 09:58:20 +08:00
Yin Fengwei 8f57c61da9 dm: Add teardown callback for mevent in uart_core
To avoid the race issue for mevent in uart, we introduce the
teardown callback to handle resource free case.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-27 09:58:20 +08:00
Yin Fengwei 72d1fa503a dm: refine the uart_core
Make uart_init and uart_deinit internal functions. And make
uart_set_backend/uart_release_backend cover uart_init/uart_deinit
function.

This will make mevent teardown callback adding easier for uart_core.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-27 09:58:20 +08:00
Tw e5c12a64d5 Makefile: add install-samples-up2
Add a rule to add UP2 related samples in rootfs.

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-12-26 16:19:59 +08:00
Shuo Liu 536ce5fb27 dm: remove unnecessary ioreq status changing from DM
We will mark ioreq as COMPLETE in VHM via IC_NOTIFY_REQUEST_FINISH
ioctl. vm_notify_request_done can do it. So remove this one.

Tracked-On: #1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-26 13:49:44 +08:00
Shuo Liu 2d1ddd8876 dm: Add vm_clear_ioreq to clear ioreq status
VHM will provide a ioctl to clear all IO requests' status. This is
useful to handle ioreqs in VM normal reboot and emergency reboot.

Tracked-On: #1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-26 13:49:44 +08:00
Shuo A Liu 59c6140347 dm: use snprintf to replace sprintf
Also remove the '\n' from the hugetlb's file name.

Tracked-On: #2133
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2018-12-25 18:40:04 +08:00
Shuo A Liu 4b3ebf69c7 dm: use strncpy to replace strcpy
Tracked-On: #2133
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2018-12-25 18:40:04 +08:00
Shuo A Liu b3ad44d4c1 dm: use strnlen to replace strlen
Tracked-On: #2133
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2018-12-25 18:40:04 +08:00
Shuo A Liu 3e0b06cfd6 dm: Fix some issues from string operations
The patch fix some string operations issues and also improve readability
of several snippet.

Tracked-On: #2133
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2018-12-25 18:40:04 +08:00
Yin Fengwei f6ae835137 dm: flush the input/output during tty open.
Discard the input/output data when open tty file. To avoid the
mevent callback is triggered immediately when the fd is added to
epoll.

Also update the uart_drain only read the data from tty file when
fifo has available space.

Tracked-On: #2159
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-23 22:35:09 +08:00
Conghui Chen 44bee5168e dm: virtio: fix compile issue on ubuntu
As VIRTIO_CONFIG_S_NEEDS_RESET is not defined in standard virtio header
file on ubuntu, there will be compile issue. so add
VIRTIO_CONFIG_S_NEEDS_RESET to fix it.

Tracked-On: #2145
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-21 19:43:16 +08:00
Conghui Chen 5253ac7af5 dm: virtio: refine header file
Reuse linux common virtio header file and remove the repetitive
definition.

Tracked-On: #2145
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-21 15:27:01 +08:00
totoroow 97a7395183 dm: pass mac seed not to use vm name on UP2
Physical NIC mac address is used for generate UOS mac address.
This patch uses a new parameters to pass this information
instead of vm name.

Tracked-On: #1987
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-12-20 21:55:28 +08:00
Xiaoguang Wu 1d1d24345f DM USB: xHCI: change log level of some logs for S3 online debugging
S3 emulation is complicated and greatly dependent on system timing,
hence this patch changes log level for some important logs to help
online debugging (could output log by modifing launch_uos.sh and
without re-compiling)

Tracked-On: #1893
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-12-20 20:22:25 +08:00
Zhao Yakui e22b35e332 HV/DM: Unify the usage of aligned for structure definition with alignment
Now one macro is added to define the alignment requirement.
>#define __aligned(x) __attribute__((aligned(x)))

Some code uses the __aligned(x) to define the alignment while the other
code uses the original alignment definition.
So they are unified.

Tracked-On: projectacrn/acrn-hypervisor#2131
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 14:08:28 +08:00
Binbin Wu ccda4595bc dm: passthru: add error handling if msix table init failed
Release the resource reqeusted during msix table init if error occurs.
Change the type of the second arg of deinit_msix_table from pci_vdev to ptdev,
to align with init_msix_table.

Tracked-On: #1782
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2018-12-20 09:08:37 +08:00
Binbin Wu 3363779d8d dm: passthru: msi/msix handling revisit
Currently, the emulation of pci msi/msix can be handled by hypervisor code.
The logic in dm passthru driver can be simplified.

This patch remaps msix table to usersapce in DM passthru driver.
1. The access to the msix table in passthru driver will be trapped, and emulated by hv code.
2. The access to the config space in passthru driver will be trapped, and emulated by hv code.

So dm passthru driver no longer needs to keep the whole logic of handling msi/msix.
No need to do msix table remapping in sos kernel.
After the patch, the msix table ioremap code in vhm_dev.c can be removed.

Tracked-On: #1782
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2018-12-20 09:08:37 +08:00
Conghui Chen 2ddd24e022 dm: storage: support discard command
Support DISCARD command is meaningful when eMMC usage is high or
there are lots of remove operations. For example, when Guest
Android is running, there will be lots of files being created and
removed. However, virtio-blk BE does not support DISCARD command,
data remove operation in UOS will not trigger erase in eMMC. After
period of time, the eMMC will be consumed out, and erase must be
done by eMMC firmware before writing any new data. This causes the
eMMC performance decrease in the whole system (SOS and UOS).
To solve the problem, DISCARD should be supported in virtio-blk BE.

Tracked-On: #2011
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-18 13:21:07 +08:00
Conghui Chen f71370ad81 dm: storage: rename delete to discard
To keep consistent with kernal code, change delete to discard.

Tracked-On: #2011
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-18 13:21:07 +08:00
Long Liu 5ab68eb97b dm: hw: Replace sscanf with permitted string API
Replace sscanf in device model hw directory

Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-17 19:17:29 +08:00
Long Liu 63b814e7e9 dm: hw: Replace strlen with strnlen
Replace strlen function with strnlen function in device-model

Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-17 19:17:29 +08:00
Long Liu eab7cd47ae dm: hw: Replace sprintf with snprintf
Replace function sprintf with snprintf in device model

Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-17 19:17:29 +08:00
Xiaoguang Wu d2627ecfcc DM USB: xHCI: fix an issues for failing to enumerate device
This is an obvious bug, which releases memory but still access the
data on the released memory. It is risky operation, and may result
failing to do normal enumlation process. This patch is used to fix
it.

Tracked-On: #1893
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-12-17 13:31:00 +08:00
Xiaoguang Wu 1c3344b782 DM USB: xHCI: change log level for S3 process
The USB S3 virtualization logic is complicated and heavily affected by system
timing. To make the debugging work easily, change related log level to facilitate
quick bug fixing.

Tracked-On: #1893
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-12-17 13:31:00 +08:00
Xie, nanlin ed5e210d91 Doc: Update GSG for v0.4 version and launch and acrn.conf sample script
Signed-off-by: Xie, nanlin <nanlin.xie@intel.com>
2018-12-15 10:12:44 -08:00
Yin Fengwei 73ab727434 dm: set correct thread name
When issue happen, we could identify which thread is impacted.
This could help stability issue debugging.

Tracked-On: #2037
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-14 19:50:50 +08:00
Jian Jun Chen cb31381561 dm: vhost: remove support for non-msix devices
irqfd only supports msix devices. In the current code a mevent is
added to poll the callfd from userspace to support intx devices.
This patch removes the support for non-msix devices since they are
not used in the current device model.

Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-14 19:49:55 +08:00
Jian Jun Chen b29fc619af dm: virtio-net: apply new mevent API to avoid race issue
Teardown callback is provided when mevent_add is called and it is
used to free the virtio-net resources.

Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-14 19:49:55 +08:00
Jian Jun Chen 4f36244fef dm: virtio-console: apply new mevent API to avoid race issue
Teardown callback is provided when mevent_add is called. A ref_count
is added to virtio_console data structure. Teardown callback needs to
free the resources of the backend and when the ref_count of the
virtio_console is zero the whole virtio-console is freed.

Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-14 19:49:55 +08:00
Jian Jun Chen baf8f8bdbf dm: virtio-input: apply new mevent API to avoid race issue
Teardown callback is provided when mevent_add is called and it is
used to free the virtio-input resources.

Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-14 19:49:55 +08:00
Xiaoguang Wu c2df4a8557 DM USB: xHCI: no wait logic implementation for S3
On Intel Apllo Lake platform, the VBus will drop after the SOC suspended,
hence during the SOS resuming process, there will be a disconnecting event
and a connecting event sent to each native USB device in order.

This patch will use new strategy for S3 resuming emultion.
  1. The DM set PORTSC register to 'no device attached' state when S3
     suspending started,
  2. SOS resuming starts and do nothing for device disconnecting event,
  3. 'Cache' device connecting event and don't report it to UOS,
  4. UOS believe no device attached due to PORTSC register state and
     begin to clear the resource allocated for the device before S3
     suspending,
  5. DM receives the Disable Slot command from UOS and report the 'cached'
     device connecting event to UOS, hence trigger the emulation behavior
     for the device.

The purpose of this strategy is to let UOS resuming proceed as quickly as
possible, which means the UI will be turned on quickly to user.

Tracked-On: #1893
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-12-14 19:40:44 +08:00
Xiaoguang Wu 82659831f0 DM USB: xHCI: refine emulation for command XHCI_CMD_RS
According to xHCI spec 5.4.1.1, this command hasn't ask to clear
PORTSC for R/S handling. So the PORTSC should always present the
physical usb bus status.

The old implementation changes the PORTSC according whether the
pci_xhci_dev_emu struct is allocated, it is not consistent with
spec and this patch is used to fix it.

Tracked-On: #1893
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-12-14 19:40:44 +08:00
Xiaoguang Wu e5c98e6d9a DM USB: add usb_dev_path_cmp function for convenience
Comparing two USB devices' path is frequently used operation, abstract
it as an seperated function for convenience.

Tracked-On: #1893
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-12-14 19:40:44 +08:00
Xiaoguang Wu 6c1ca13767 DM USB: xHCI: remove the waiting 5 seconds wa for s3
This workaround will delay the UOS resuming for 5 seconds, this
behavior is not right and should be replaced by dynamic style.

Tracked-On: #1893
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-12-14 19:40:44 +08:00
yingbinx 6b998580d6 Fix KW issues for tpm_emulator
There are several KW issues which uninitialized variables
are used. This patch will fix those KW issues.

Signed-off-by: weideng <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
2018-12-14 09:05:28 +08:00
Yang Liang fbaecde6bb DM USB: xHCI: Fix banned API issue.
In USB mediator, sscanf, strtok and atoi API is banned, so replace them
with permitted API function.

Tracked-On: #1254
Signed-off-by: Yang Liang <liang3.yang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-13 13:24:55 +08:00
Peter Fang e835f5f5d2 dm: enforce data size when accessing PCI BARs
Always enforce data size when using BAR access functions.

Currently, the size serves as a hint to the BAR access functions and
these functions are expected to behave accordingly. Some of the access
functions, e.g. virtio ones, don't always truncate the data but expect
the caller to take care of the data size. This causes problems with
OVMF's virtio drivers during I/O instruction emulation because RAX can
contain junk bits that shouldn't be written to the device.

v1 -> v2:
- improve readability

Tracked-On: #1935
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-13 13:22:44 +08:00
Peter Fang d8c4e7d367 dm: add option to boot OVMF from acrn-dm
Use '--ovmf <OVMF image location>' when launching acrn-dm.

Tracked-On: #1832
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-13 09:56:09 +08:00
Peter Fang 9e97fd0680 dm: add BIOS/ROM image loading support at High BIOS region
Generic infrastructure for loading BIOS/ROM and providing EPT pages at
High BIOS region.

The size of High BIOS is rounded up to a multiple of 2MB.

v2 -> v3:
- refine mmap_hugetlbfs* to reduce code replication

v1 -> v2:
- make this code generic instead of OVMF-specific

Tracked-On: #1832
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-13 09:56:09 +08:00
Peter Fang 653a57958b dm: query and save image size during initial checking
This is preparation for the upcoming High BIOS work.

Tracked-On: #1832
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-13 09:56:09 +08:00
Yan, Like a80f08ebad dm: add launch_uos.args sample file for AaaG
A sample args file is added, which will be linked to /usr/share/acrn/conf/add/[vmname].args at integration time.
Because it is needed for AaaG one-key startup enabled build.

Tracked-On: #2040
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-13 09:09:41 +08:00
Tw bb768904ab config: add up2-sbl board related configs
Add up2-sbl's stuff including (launch_uos script, sos_bootargs and hv
config).

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-12 13:23:28 +08:00
Junjie Mao 064a31067f tools: vmcfg: use defconfig instead of default values in Kconfig
The current vmcfg uses the default values in Kconfig when a previous .config
does not exist. This leads to additional complexity to silentoldconfig.py which
has different logic depending on the environment variable 'BOARD'. This also
blocks the effort to make the top-level Makefile recognize BOARD because any
environment variable set in the top-level Makefile cascades to the other
Makefiles, leading the work around above to fail.

This patch introduces a generic defconfig for vmcfg and simplifies
silentoldconfig.py to always fail when neither .config nor the specified
defconfig exists.

Tracked-On: #1995
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-12 13:23:28 +08:00
Jie Deng ed1c576d08 dm: pass mac seed not to use vm name
Physical NIC mac address is used for generate UOS mac address.
This patch uses a new parameters to pass this information
instead of vm name.

Tracked-On: #1987

Signed-off-by: Jie Deng <jie.deng@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-12 13:22:18 +08:00
Binbin Wu a1435f332b dm: bios: update vSBL to V1.1
vSBL Version 1.1
- Change:
	Update vFastboot to v1.1
	Pass vrpmb key to vFastboot.

Tracked-On: #2028
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2018-12-12 12:53:41 +08:00
Jian Jun Chen 2ef06450dc dm: virtio-input: ignore all MSC events from FE
EV_MSC is configured as INPUT_PASS_TO_ALL in input driver. There is
a loop in the use case of virtio-input. They should not be forwarded
back to BE since they have already been sent to native driver before
sending to FE.

Tracked-On: #2006
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-12 09:31:57 +08:00
Yin Fengwei 19fb5fa03c dm: adjust the sequence of destroy client and wait for vm_loop exit
To fix the issue that watchdog reset hang issue. At previous change,
we assume the reset comes from guest. But watchdog reset or dm killed
by signal is different. It's possible the vm_loop stick on ioreq
attaching.

The new fixing has two parts:
- fixing from kernel side to remove the race issue in ioreq attach,
  req_complete_notify and client destory.
- Move the client destroy before waiting of vm_loop exit.

Tracked-On: #1986
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-12 09:13:53 +08:00
Long Liu c5d827ab1f ACRN: Add runC container sample config file
This patch adds the runC container config file, we will run acrn-dm
in runC container, and set acrn QoS parameters based on runC.
In the config file we mount SOS root directory to the container and
disable network/mount/ipc namespace.

Tracked-On: projectacrn/acrn-hypervisor#2020
Signed-off-by: Long Liu <long.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-12 09:11:52 +08:00
Yang Liang da0cf3af71 DM: xHCI: unbind slot id and ndevices relationship.
After mutiple usb devices send enable slot commnad and get slot id each
other, address device setup flow is not sorted by slot id. According to
current design, it will casue assert failure. This patch takes off this
restriction.

Tracked-On: #2017
Signed-off-by: Yang Liang <liang3.yang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-12 09:11:29 +08:00
Yin Fengwei 7fce2462a0 dm: apply new mevent API to avoid race issue in mei
Pass teardown callback when add mevent in mei mediator code.
Which could avoid run_callback calling after the related data
structure is freed.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-07 20:21:33 +08:00
Yin Fengwei 64d9c59aa1 dm: enhence the mevent API
There is one race issue between mevent callback (which is called
in mevent_dispatch thread) and mevent_delete (which could be called
in dev thread). And the callback is called after mevent_delete.

libevent have the exactly same issue. The issue is decripted here:
https://github.com/libevent/libevent/blob/master/whatsnew-2.1.txt

The fixing is:
We introduce a teardown callback to mevent and make sure there is
no race issue between callback and teardown call.

This patch updates the mevent API and the caller as well.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-07 20:21:33 +08:00
Yin, Fengwei eec3a342c4 dm: fix the race issue in mevent_del
Peter, Thomas and Shuo raised one race issue in mevent_del. It
happens like following:

      Thread                     mevent_dispatch Thread
 mevent_delete_event
    epoll_ctl_del
    free(evp)
                               mevent_handle with freed evp

The fixing is adding sync between mevent_delete_event and
mevent_handle in mevent_dispatch.

      Thread                     mevent_dispatch Thread
 mevent_delete_event
    add evp to del_list
    notify mevent_dispatch
    return
                                  mevent_handle
                                  Remove evp from del_list
                                  Remove evp from epoll_fd
                                  closefd()
                                  free(evp)

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-07 20:21:33 +08:00
ailin,yang 87e7bdb90c DM: updating launch_uos.sh
this patch is for updating path of the UOS image in launch_uos.sh script to adapt latest getting started guide, 

Tracked-On: #2003 
Signed-off-by: Ailun258 <ailin.yang@intel.com>
2018-12-07 19:31:25 +08:00
Yin Fengwei 3ca64c5b02 dm: add "break" removed by mistake.
The tpm patch delete the "break" for CMD_OPT_DEBUGEXIT branch.

Tracked-On: #1978
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-05 19:31:09 +08:00
Xiaoguang Wu 9d4b5d7e1b DM USB: add some preparing time for xHCI emulation before resuming.
If the USB kernel drives and devices of SOS are not available and
functional ready after UOS is resumed from frozen state, the comming
USB command from UOS will cause a disaster because the DM has no
resourse to to emulation.

This patch add a dynamic time span (could change according to number
of native USB devices attached) to give USB drivers and devices of
SOS an opportunity to be ready.

Tracked-On: #1893
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-12-04 19:59:00 +08:00
Xiaoguang Wu b159d66fb3 DM USB: refine the polling thread for libusb events
The thread function usb_dev_sys_thread is the source of libusb events,
which is also the basis of USB/xHCI emulation. During S3 process,
function libusb_handle_events_timeout may fail and return -1, which
could result of exit of the thread (BTW, this failure is resulted from
USB native reseting behavior during S3). Under this situation, the emulation
of USB/xHCI could never continue.

This patch fix this issue by continuing to call libusb_handle_events_timeout
even it reture -1. The return value will be finally ok after S3 process is
completed.

This patch will continue poll after failure and hence fix this issue.

Tracked-On: #1893
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-12-04 19:59:00 +08:00
Xiaoguang Wu 966c587260 DM USB: xHCI: fix potential NULL pointer issue.
During S3 process, the dev in the function pci_xhci_device_doorbell
may be set to NULL when disconnection is detected by DM. This patch
is used to remove this risk.

Tracked-On: #1893
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-12-04 19:59:00 +08:00
Xiaoguang Wu 5b39fd0ed3 DM USB: xHCI: fix error logic of allocating xHCI slot
The 'slot_allocated[]' field of pci_xhci_vdev is used as flag of
slot allocation. In current design, this variable is not set to
false in disconnection callback 'pci_xhci_native_usb_dev_disconn_cb'.
This patch is used to fix it.

Tracked-On: #1894
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-12-04 19:59:00 +08:00
Xiaoguang Wu 32c4ce9b9a DM USB: xHCI: refine the xHCI S3 process
In the old implementation, function vm_get_suspend_mode is used
as the interface to check whether the UOS is in the S3, That is
not saft way.

This patch use Port Link State (PLS) to substitute the old logic.
According to xHCI spec 5.4.8, the PLS should be U3 during the
UOS is in the S3 state.

Tracked-On: #1893
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-12-04 19:59:00 +08:00
Xiaoguang Wu 9e471d7258 DM USB: xHCI: refine the PLC bit emulation logic during S3
According to xHCI 5.4.8, the Port Link State Change (PLC) bit
should not be set to 1 during suspend process. This patch is used
to fix it.

Tracked-On: #1893
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-12-04 19:59:00 +08:00
Xiaoguang Wu 29e81501c5 DM USB: xHCI: refine error handling logic for ctrl transfer
Under current implementation, when USB control transfer failed
with Endpoint Stall error, there is no response reporting to UOS.
This logic will result of timeout in UOS kernel and hence a longer
enumeration process.

This patch reports the Stall Error to UOS by xHCI Completion Event,
which will fix this issue.

Tracked-On: #1895
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-12-04 19:59:00 +08:00
Jie Deng b261e74dd5 dm: virtio poll mode support for RT
Device trap has great impact on latency of real time (RT) tasks.
This patch provide a virtio poll mode to avoid trap.

According to the virtio spec, backend devices can declare the
notification is not needed so that frontend will never trap.
This means the backends make commitment to the frontends they have a
poll mechanism which don’t need any frontends notification.

This patch uses a periodic timer to give backends pseudo notifications
so that drive them processing data in their virtqueues. People should
choose a appropriate notification peroid interval to use this poll
mode. Too big interval may cause virtqueue processing latency while
too small interval may cause high SOS CPU usage. The suggested interval
is between 100us to 1ms.

The poll mode is not enabled by default and traditional trap
notification mode will be used. To use poll mode for RT with interval
1ms. You can add following acrn-dm parameter.

	--virtio_poll 1000000

Tracked-On: #1956
Signed-off-by: Jie Deng <jie.deng@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-04 18:27:53 +08:00
Minggui Cao e2d093989d DM: remove ignored pci device from SOS bootargs
now hypervisor will support to hide ignored PCI device from SOS,
it need not modify SOS PCI driver to support this feature.

Tracked-On: #1923
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-03 13:20:35 +08:00
Libin Yang 7f08ad8375 use 4 vqs
Signed-off-by: Libin Yang <libin.yang@intel.com>
Tracked-On: #1915
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-03 10:35:38 +08:00
Zhu Yingjiang 333629682a change the vq count and vendor id
Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com>
Tracked-On: #1915
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-03 10:35:38 +08:00
Pawel Furtak 9bf7dd5ddc Enable audio virtualization for AaaG
Based on existence of /dev/vbs_k_audio file
launch AaaG with proper audio virtualization mode

Signed-off-by: Pawel Furtak <pawel.furtak@intel.com>
Tracked-On: #1915
Reviewed-by: Yu Wang <yu1.wang@intel.com>
2018-11-30 15:16:16 +08:00
Junjie Mao 584f6b7255 doc: replace return with retval
`@return` is dedicated for brief description of return values, not for comments
stating actual return values. In addition, sphinx + breathe does not join
multiple adjacent `@return`. This results in multiple `Return` sections in the
generated document, which is confusing.

This patch replaces `@return` with `@retval` for the lists of return
values. Adjacent `@retval` can be joined into one list by breathe.

v1 -> v2:

* Replace return value descriptions like `negative` and `positive` with
  expressions like `<0` and `>0` in `@retval`.
* Keep the list of `@retval` comprehensive, even when there is a `@return` to
  generally describe what the return value means.
* Drop duplicated `@return` when it does not give more information than the
  `@retval` list.

Tracked-On: #1595
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2018-11-30 14:55:17 +08:00
Junjie Mao 97eb72a4a0 doc: always use 'None' for functions not returning a value
It is preferred to state the absence of a return value explicitly in the
doxygen-stile comments. Currently there are different styles of doing this,
including:

  @return None
  @return NULL
  @return void
  @return N/A

This patch unifies the above with `@return None`.

Tracked-On: #1595
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2018-11-30 14:55:17 +08:00
Zheng, Kankan cbe1b74eee HDCP virtio back-end driver
Initial HDCP back-end driver.

Signed-off-by: Romli, Khairul Anuar <khairul.anuar.romli@intel.com>
2018-11-30 14:45:24 +08:00
Yu Shiqiang fa012e6987 CoreU virtio back-end driver
v4 -> v5
    Replace strcpy with strncpy
    Refine resource free if error happens
    Remove meaningless *in_progress* label for pthread wait/signal
    Rename the coreu thread routine name (virtio_coreu_thread)

v3 -> v4
    Move setsocketopt to connect_to_daemon
    Cleanup coreu file descriptor after close
    Reconnect CoreU daemon if the socket descriptor is invalid

v2 -> v3
    Move the daemon connection to vdev_init
    Diagram the CoreU virtualization architecture
    Create a seperate thread for sending and receving the CoreU message
    Change the socket name

v1 -> v2
    No change

v1
    Initial CoreU back-end driver

Signed-off-by: Yu Shiqiang <shiqiang.yu@intel.com>
2018-11-30 14:45:24 +08:00
Geoffroy Van Cutsem aefe9168d1 Update 'launch_uos.sh' script for UEFI platforms
Update the 'launch_uos.sh' script for UEFI platforms to point at the latest
iot-lts2018 kernel installed by means of the
/usr/lib/kernel/default-default-iot-lts2018 symlink which is set-up by the
kernel-iot-lts2018 bundle.

Update the Getting Started Guide to reflect this minor change.

Tracked-On: #1927
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-29 10:57:13 +08:00
Qi Yadong 839680f09b DM: build TPM2 ACPI table when TPM device enabled
Add TPM2 ACPI table build function.

If virtual tpm device is initialized successfully, then create
corresponding TPM2 ACPI table.

Tracked-On: #1924
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Reviewed-by: Zhu Bing <bing.zhu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-29 09:19:16 +08:00
Qi Yadong aae70db6b9 DM: Add support for virtual TPM enabling
Support TPM enable option when launch UOS.

New option: "--vtpm sock_path=$PATH_OF_SWTPM_SOCKET".
If valid option parsed, then init virtual tpm device.

Tracked-On: #1924
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Reviewed-by: Zhu Bing <bing.zhu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-29 09:19:16 +08:00
Qi Yadong 7df90a2527 DM: Support TPM2 CRB device virtualization
Full virtualized TPM CRB device.

The TPM CRB module will handle TPM2 MMIO access. It will forward
the command/data to TPM emulator for command processing if there
is a valid TPM command.

Tracked-On: #1924
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Reviewed-by: Zhu Bing <bing.zhu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-29 09:19:16 +08:00
Qi Yadong 4b83e37c7a DM: tpm emulator to communicate with swtpm
This patch will create control channel and command channel
so as to communicate with swtpm. Based on the 2 channels,
a set of APIs will be implemented and exposed.

Tracked-On: #1924
Signed-off-by: Deng Wei <wei.a.deng@intel.com>
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
Reviewed-by: Zhu Bing <bing.zhu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-29 09:19:16 +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
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
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
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
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
Shuo Liu 611944c018 dm: Fix race between ioreq client destroy and access
vcpu thread need to exit when doing VM full reset and VM shutdown.
Change the code to align the logic. This also can fix race condition
between ioreq client destruction and accessing.

Tracked-On: #1857
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-20 13:26:33 +08:00
Yonghua Huang 2fa67a4471 HV: clear memory region used by UOS before it exit
this patch fixes such an information leaking issue:
in case that after a UOS is destroyed, its memroy
will be reclaimed and maybe re-allocated for a new UOS,
then the previous UOS sensitive data in memory may
be leaked to the new UOS.

Tracked-On: #1825
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-16 09:13:34 +08:00
Geoffroy Van Cutsem a03452794f DM: update User OS launch script with v0.3 CL and kernel numbers
Update the User (guest) OS launch script with the Clear Linux
version used with ACRN v0.3 as well as the corresponding kernel
version.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-12 10:43:03 -08:00
ailin,yang 5c8e4c38b7 DM: update clear Linux version
1, update Clear Linux version to 26120 
2, update kernel name to *iot-lts2018* 

Signed-off-by: Ailun258 ailin.yang@intel.com
2018-11-10 11:17:22 -08:00
Zhao Yakui 66f133bf45 DM: Fix the typo error in checking the /dev/vbs_ipu file
The /dev/vbs_ipu is used by the backend driver of IPU mediator on SOS kernel
If the file of /dev/vbs_ipu exists, it indicates that IPU works in mediator mode.
Other it will fall back to the pass-through mode.
But the commit 969f7cf071 doesn't check the file of /dev/vbs_ipu correctly.
It should be -e instead of -f.

Tracked-on: https://github.com/projectacrn/acrn-hypervisor/issues/1373
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Wu, BinBin <binbin.wu@intel.com>
2018-11-09 11:26:59 +08:00
yuhong.tao@intel.com c4161c8784 dm: uart: fix UOS console output to stdin
At devicemodel/hw/uart_core.c, struct ttyfd has only one file
descriptor for uart backend device, that is OK if DM uart open
a tty characteor device under /dev/ for reading, writing and
terminal operating.

When use stdio as backend tty device, there are 2 fds, stdin/stdout.
DM should read from 'stdin' and output to 'stdout'. But ttyfd just
has one fd, and is only for 'stdin', so dm has to output to stdin,
too, not to stdout.

That cause a problem: if use stdio for uart backend, you can't
redirect UOS console to any other files. Because stdout is not used.

We hope to store information from VM console to system journal,
when UOS is launched by Acrnd automatically. The systemd need to
redirect stdout of dm to system journal files, but it can't be done.

So we can split the 'fd' of struct ttyfd to 'fd_in' & 'fd_out'.
they are same when use tty device; And they are different when use
stdio, 'fd_in' is for stdin and 'fd_out' is for stdout.

Tracked-On: #1759
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Like Yan <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-11-08 15:14:15 +08:00
Minggui Cao b58817273d DM: add interrupt storm monitor params in cmdline
To support expose "interrupt storm monitor" params setting to user;
it is easy to adjust the params in launch UOS script.

Tracked-On: #1724
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-08 14:43:05 +08:00
Minggui Cao ad1cbb7623 DM: add interface to set intr storm monitor params
modify and add interface to set interrupt monitor params;
it can be set by acrn-dm input arguments like following:
--intr_monitor 10000,10,1,100

the 4 params order is:
    interrupt storm theshold per second,
    probe period to get interrupt data,
    pass-through devices' interrupt injection delay time,
    delay duration, after it, stop injection & restore to normal

Tracked-On: #1724
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-11-08 14:43:05 +08:00
Zhi Jin 36aaaa1cfd DM NPK: unmap the MMIO in pci_npk_deinit
Otherwise, after UOS crashes, the PTE for the MMIO may be added
again.

Tracked-On: #1745
Signed-off-by: Zhi Jin <zhi.jin@intel.com>
2018-11-08 09:06:17 +08:00
Binbin Wu 78dd92e4ed DM: sos_bootargs: split sos_bootargs into multiple lines
Difficult to review the changes of sos_bootargs when the args is a single line.
Split sos boot args into multiple lines.

Tracked-On: #1730
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2018-11-07 09:21:13 +08:00
Yuan Liu 65a2613ab6 IOC mediator: fix wakeup reason issue when UOS resuming
IOC mediator should keep sending acnrd boot reason until received
UOS heartbeat init message, then turn to send SOS wakeup reason
through read native cbc lifecycle cdev.

Tracked-On: #1727
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-06 16:18:35 +08:00
Xinyun Liu ad1e2ab678 DM/sos_bootargs: remove unused parameters for graphics
remove these options from legacy release:

i915.tsd_init=7 i915.tsd_delay=2000
i915.enable_preemption=1 i915.context_priority_mode=2

Tracked-On: #1697
Signed-off-by: Xinyun Liu <xinyun.liu@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-06 13:13:36 +08:00
Zhao Yakui 969f7cf071 DM:Check the device file of /dev/vbs_ipu to determine IPU mode
The /dev/vbs_ipu is used as the backend driver of IPU mediator on SOS kernel.
If the file of /dev/vbs_ipu exists, it indicates that IPU works in mediator mode.
Other it will fall back to the pass-through mode.

Tracked-on: https://github.com/projectacrn/acrn-hypervisor/issues/1373
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-11-05 14:45:38 +08:00
Shuo Liu d261b4bce2 doc: update virtio related functions doc comments
Update some virtio, VBS-K, vhost APIs documents.

Tracked-On: #1595
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
2018-11-04 20:32:50 -08:00
Shuo Liu ea801a1672 dm: Remove unused duplicated API dm_gpa2hva
paddr_guest2host has same function with dm_gpa2hva. And There is no
usage of dm_gpa2hva. Remove it.

Tracked-On: #1595
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Fengwei Yin <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-04 20:32:50 -08:00
Jian Jun Chen 94dadc1d14 dm: virtio-input: ignore MSC_TIMESTAMP from guest
(EV_MSC, MSC_TIMESTAMP) is added to each frame just before the
SYN event since kernel 4.15. EV_MSC is configured as
INPUT_PASS_TO_ALL. In the use case of virtio-input, there is
a loop as follows:
- A mt frame with (EV_MSC, MSC_TIMESTAMP) is passed to FE.
- FE will call virtinput_status to pass (EV_MSC, MSC_TIMESTAMP)
  back to BE.
- BE writes this event to evdev. Because (EV_MSC, MSC_TIMESTAMP)
  is configured as INPUT_PASS_TO_ALL, it will be written into
  the event buffer of evdev then be read out by BE without
  SYN followed.
- Each mt frame will introduce one (EV_MSC, MSC_TIMESTAMP).
  Later the frame becomes larger and larger...

This patch fixed above issue by ignoring MSC_TIMESTAMP from guest.
Besides that timestamp is added for every status event from guest
before writing to evdev.

Tracked-On: #1670
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-02 13:42:43 +08:00
Minggui Cao 74a5eec3a7 DM: change SOS bootargs console ttyS0 to ttyS2
change it to match with release version.

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