Commit Graph

1003 Commits

Author SHA1 Message Date
Conghui Chen 859af9e03d DM: virtio-i2c: add backend interface
Add backend interface for virtio-i2c, it will parse the parameters,
maintain the info for native i2c device, remap the slave address and
dispatch the requirement from FE. When there is only one native adapter,
will not remap the slave address.

Usage for virtio-i2c:

virtio-i2c,<bus>[:<slave_addr>][:<slave_addr>]
	[,<bus>[:<slave_addr>][:<slave_addr>]]

e.g.
1.  virtio-i2c,4:1C
    SOS:
        mount /dev/i2c-4, slave addr is 0x1C.
    Guest OS:
        /dev/i2c-x
           |- 0x1C

2. virtio-i2c,4:1C:2F,6:70
    SOS:
        /dev/i2c-4, slave addr 0x1C and 0x2F
        /dev/i2c-6, slave addr 0x70
    Guest OS:
        /dev/i2c-x
           |- 0x1C
           |- 0x2F
           |- 0x70

Tracked-On: #3357
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2019-07-05 10:20:21 +08:00
Conghui Chen a450add672 DM: virtio-i2c: add support for virtio i2c adapter
Add virtio i2c adapter BE driver.

Tracked-On: #3357
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2019-07-05 10:20:21 +08:00
Yonghua Huang 2751f137fd dm: remove Execute attribute of usb_pmapper.c
code cleanup

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-05 09:51:54 +08:00
Gao Junhao e837116691 dm: clean up assert in virtio_rnd.c
clean up assert in virtio_rnd.c

Tracked-On: #3252
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-05 09:39:42 +08:00
Yonghua Huang 842da0ac1e dm: cleanup assert in core.c
- check input by condition check, instead of assert.
 - remove redundant header file including for some files.

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
2019-07-05 09:36:02 +08:00
Peter Fang cb8bbf7bea dm: clean up the use of errx
errx() does not require an additional exit().

Tracked-On: #3252
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yin, Fengwei <fengwei.yin@intel.com>
2019-07-03 13:19:43 +08:00
Peter Fang 82f7720ae7 dm: vhpet: clean up asserts
Remove the use of assert() in vHPET.

Tracked-On: #3252
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yin, Fengwei <fengwei.yin@intel.com>
2019-07-03 13:19:43 +08:00
Peter Fang aac8275098 dm: vpit: clean up asserts
Remove the use of assert() in vPIT.

Tracked-On: #3252
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yin, Fengwei <fengwei.yin@intel.com>
2019-07-03 13:19:43 +08:00
Yan, Like 81f9837e8a Revert "dm: add "noapic" to rt-linux kernel parameters"
This reverts commit c42b41fe2b.
Kernel will stay in xapic mode with this boot arg, lapic won't be passthru, so revert.

Tracked-On: #3227
Signed-off-by: Yan, Like <like.yan@intel.com>
2019-07-03 13:18:50 +08:00
Liu Xinyun 5a9a7bcd31 dm: gvt: clean up assert
handle the error if failed to create GVT device.

- remove assert
- clean up the allocated resource

V2: refine code and clean up the allocated resource

Tracked-On: #3349

Signed-off-by: Liu Xinyun <xinyun.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-03 09:40:15 +08:00
Liu Xinyun bd3f2044eb dm: hyper_dmabuf: clean up assert
validate fd before use it

Tracked-On: #3349

Signed-off-by: Liu Xinyun <xinyun.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-03 09:40:15 +08:00
Liu Xinyun 5650183471 dm: gc: clean up assert
remove unused head file

Tracked-On: #3349

Signed-off-by: Liu Xinyun <xinyun.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-03 09:40:15 +08:00
Yan, Like c42b41fe2b dm: add "noapic" to rt-linux kernel parameters
This commit adds "noapic" boot option to rt-linux, to skip IOAPIC probe.

Tracked-On: #3227
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-28 09:36:41 +08:00
Conghui Chen 8badd0b486 DM: virtio-console: bug fix for parsing options
Bug fix for parsing options, as the vritio-console support multiple
virtio serial ports, and the parameters is split by ',':

virtio-console,[@]stdio|tty|pty|file:portname[=portpath]\
   [,[@]stdio|tty|pty|file:portname[=portpath]]

But the previous patch "refine console options parse code" not
cover this case, can only parse one port config. Fix it in this patch.

Tracked-On: #3337
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2019-06-27 16:42:09 +08:00
Binbin Wu ad6f54b99a dm: sample: remove deprecated sos_bootargs files
SOS bootargs is specified in vm_configurations.h in different scenarios.
The files in devicemodel/samples/<board>/sos_bootargs_*.txt are not used anymore.
Remove these deprecated files to avoid confusion.

Tracked-On: #3214
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-06-27 15:29:21 +08:00
Xiaoguang Wu 31e23cd09c DM USB: clean up the assert usage
Remove assert in USB mediator code.

Tracked-On: #3252
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-26 22:50:38 +08:00
Long Liu 7176e813ed ACRN: dm: Modify the runC.json for NUC.
The path modify the configuration for the runC container. There have
three changes for the configuration.
1、args [ "sh" ]: this is an example parameter and when the VM is started,
the parameter will be replaced by the launch_UOS script.
2、The linux capabilities will guarantee the Acrn-dm have enough capabilities
to run in container. For more infomation about the capalility you can refer
http://man7.org/linux/man-pages/man7/capabilities.7.htm
3、Move the rootfs to the parent directory, so all the container can share
the same rootfs.

Tracked-On: projectacrn#2020
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-06-26 15:22:33 +08:00
yingbinx fbf16d7327 DM: virtio_rpmb: clean up assert
clean up assert from virtio rpmb module.

Tracked-On: #3252
Signed-off-by: dengwei <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2019-06-24 18:51:44 +08:00
Jian Jun Chen 56469f3edc dm: refine assert usage
Remove unnecessary assert and add error handling when required.

Tracked-On: #3252
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-24 11:57:05 +08:00
Gao Junhao 93b4cf57fa dm: clean up assert in virtio.c
clean up assert in virtio.c

Tracked-On: #3302
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-22 21:42:32 +08:00
Gao Junhao c265bd5552 dm: clean up assert in virtio_audio.c
clean up assert from virtio_audio

Tracked-On: #3301
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-22 21:42:14 +08:00
Gao Junhao 14a93f7475 dm: clean up assert in virtio_input.c
clean up assert in virtio_input.c

Tracked-On: #3303
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-22 21:41:57 +08:00
Yan, Like 0a6baaf4d3 dm: samples: use stdio as vxworks console by default
Current launch script leaves stdio to OVMF console and, vxworks console to pty, so users
need to use additional tool like minicom to connect to pty device to use vxWorks.

To be more convinient, this commit changes the vxWorks to use the stdio by default, and OVMF
is not availabe by default.

Tracked-On: #3069
Signed-off-by: Yan, Like <like.yan@intel.com>
2019-06-22 21:41:40 +08:00
Yuan Liu 5cbda22d29 dm: virtio_gpio: clean up assert
This patch is to clean up assert from virtio-gpio

Tracked-On: #3252
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 22:25:11 +08:00
Yuan Liu 1e23c4dc41 dm: ioc: clean up assert
This patch is to clean up assert from ioc

Tracked-On: #3252
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 22:25:11 +08:00
Shuo A Liu db7e7f1c44 dm: platform: clean up assert() for some platform devices
Tracked-On: #3252
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-06-20 11:21:51 +08:00
Shuo A Liu 1b7995387d dm: pcidev: clean up assert() for some pci devices
Tracked-On: #3252
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-06-20 11:21:51 +08:00
Shuo A Liu 2b3dedfb9b dm: pci: clean up assert() in pci core
Tracked-On: #3252
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-06-20 11:21:51 +08:00
Conghui Chen d0e0871283 dm: virtio-block: clean up assert
This patch is to clean up assert from virtio-block

Tracked-On: #3252
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:56:29 +08:00
Conghui Chen 3ef385d6c4 dm: ahci: clean up assert
This patch is to clean up assert from achi.

Tracked-On: #3252
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:56:29 +08:00
Conghui Chen 4145b8af6e dm: block: clean up assert
This patch is to clean up assert for block interface.
'magic' is removed from block structure, as the user should make sure
the block device is created and not closed when access to it.

Tracked-On: #3252
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:56:29 +08:00
Yonghua Huang 13228d910f dm: refine 'assert' usage in irq.c and wdt_i6300esb.c
cleanup 'assert' usage to avoid possible software vulnerabilities

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Yonghua Huang e6eef9b672 dm: refine 'assert' usage in pm.c and acpi.c
'assert' usage cleanup to avoid possible software vulnerabilities

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Yonghua Huang 885d503a60 dm: refine 'assert' in hugetlb.c and mem.c
cleanup 'assert' usage to avoid possible software vulnerabilities.

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Yonghua Huang 65d7d83b1c refine 'assert' usage in vmmapi.c and main.c
cleanup 'assert' to avoid possible software vulnerabilities

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Yonghua Huang dedf9befa6 dm: refine 'assert' in inout.c and post.c
- 'assert' cleanup to avoid possible software vulnerabilities.

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Yonghua Huang a2332b159a dm: refine 'assert' usage in timer.c and rtc.c
- 'assert' cleanup
 - fix memory leakage in vrtc_init()

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Yonghua Huang ec626482d2 dm: cleanup 'assert' for guest software loading module
cleanup 'assert' to avoid possible vulnerabilities.

Tracked-On: #3252
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-20 08:55:44 +08:00
Jie Deng cdc5f120f1 dm: virtio-net: clean up assert
This patch is to clean up assert from virtio-net.
Tracked-On: #3252

Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-19 08:40:13 +08:00
Tianhua Sun b0015963f5 dm: fix some potential memory leaks
This patch is to fix some potential memory leak issues

1, free mrp if the mmio_rb_lookup() function return 0;
2, free memory allocated by strdup in some error case handling.

Tracked-On: #3277
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-19 08:39:55 +08:00
Tianhua Sun 0620980fab dm: use strnlen to replace strlen
Replace strlen function with strnlen function in DM

Tracked-On: #3276
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-19 08:39:55 +08:00
Tianhua Sun 1e1244c36b dm: use strncpy to replace strcpy
Use strncpy instead of strcpy to avoid buf overflow.
Fix strncpy null-terminated issues.

Tracked-On: #3245
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-19 08:39:55 +08:00
Binbin Wu 0ea788b48e dm: passthru: remove the use of assert()
Remove the use of assert() in passthrough driver.

Tracked-On: #3252
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-06-19 08:39:20 +08:00
Gao Junhao efccdd22a0 dm: add virtio-rnd device to command line
When FE virtio devices work in polling mode, sshd.service can't start
normally and blocks at generating random bytes. When reading from
the random source, getrandom() blocks caused by no random bytes.

Tracked-On: #3268
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
2019-06-18 09:56:33 +08:00
Long Liu 48877362c6 ACRN: DM: Add new options for NUC launch_uos script.
The patch adds new argument for launch_uos script for NUC.
In the patch add "-C" parameter for launch_uos script. When launch
the script with the parameter the ACRN-dm will be launched in the
runC container. For more information about this please refer to
ACRN-dm QoS document.

Tracked-On: #2020
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Binbin Wu binbin.wu@intel.com
Reviewed-by: Geoffroy Van Cutsem geoffroy.vancutsem@intel.com
2019-06-17 19:23:44 +08:00
Kaige Fu 22f24c229b DM: Samples: Enable VxWorks as hard-rt VM
This patch adds --lapic_pt option to launch VxWorks as hard-rt VM.

Tracked-On: #3069
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-06-14 15:47:26 +08:00
Qi Yadong 8426db9309 DM: vrpmb: replace assert() with return false
Replace assert() with explicit parameter checking and error handling.

Tracked-On: #3252
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2019-06-14 09:25:20 +08:00
Yuan Liu 66943be353 dm: enable audio passthrough device.
Enable audio device by default on WaaG

Tracked-On: #3257
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-14 09:24:56 +08:00
Minggui Cao ed7f64d748 DM: add deinit API for loggers
when DM exit, it is better to call deinit_loggers
to do some cleanup work.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-06-13 13:06:51 +08:00
Minggui Cao d05349d767 DM: use pr_dbg in vrtc instead of printf
also add "\n" in the end of each log.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-06-13 13:06:51 +08:00
Minggui Cao 5ab098eae2 DM: add disk-logger configure in launch script
add disk-logger setting in nuc/up2 launch script files.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-06-13 13:06:51 +08:00
Minggui Cao c04949d993 DM: add disk-logger to write log into file system
disk-logger used to save persistent log as file in disk.
log path: /var/log/acrn-dm/

each log file size is 2MB; default 8 log files; the log
files' suffix will be increased; when file count more than 8,
the last one added, the first one is removed, like form 1-8 to
2-9 to 3-10 ...

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-06-13 13:06:51 +08:00
Minggui Cao 6fa41eee98 DM: add static for local variables
variables defined by struct logger_ops just used
in local file, so add static to them.

Tracked-On: #3012
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-06-13 13:06:51 +08:00
Xiaoguang Wu 5a9627ced8 DM USB: xHCI: refine the emulation of Stop Endpoint Command
Old implementation does nothing when Stop Endpoint cmd is received,
it is not right. The new implementation will cancel all the libusb
requests in processing.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-13 10:30:38 +08:00
Xiaoguang Wu 1be719c630 DM USB: clean-up: change name of function usb_dev_comp_req
Change it to usb_dev_comp_cb, which is more accurate for what
it does. This patch doesn't change original program logic.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-13 10:30:38 +08:00
Xiaoguang Wu 7dbde27615 DM USB: xHCI: use new isoch transfer implementation
The old implementation processes isoch TRB one by one, this method
can't support scenario which needs high performance, such as real
time USB camera video.

New implementions will compose all the isoch TRBs for one Door Bell
Ring, and give them to libusb as a single request. The test result
shows that this method could greatly improve the porfermance.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-13 10:30:38 +08:00
Xiaoguang Wu b57f6f9243 DM USB: clean-up: give shorter names to libusb_xfer and req
The names for the two variables are too long, change to shorter
name. This patch doesn't change any logic, just clean up.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-13 10:30:38 +08:00
Xiaoguang Wu adaed5c0e3 DM USB: xHCI: add 'chained' field in struct usb_data_xfer_block
The chained field could help to describe the relationship of USB
data blocks.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-13 10:30:38 +08:00
Xiaoguang Wu f2e35ab701 DM USB: save MaxPacketSize value in endpoint descriptor
Save the MaxPacketSize value for every endpoint of virtual
USB device.

Tracked-On: #3054
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-13 10:30:38 +08:00
Yan, Like 771f15cd6b dm: don't present ioapic and pic to RT VM
Per ACRN RT VM design, there is no virtual IOAPIC and virtual PIC emulated for RT VM.
This commit removes the entries of IOAPIC, PIC, PPRT and APRT in ACPI table for RT VM.

Tracked-On: #3227
Signed-off-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-06-12 14:29:50 +08:00
bing.li 509af78490 dm: Solve the problem of repeat mount hugetblfs
If you run two acrn-dm processes at the same time,
hugetblfs will be mounted twice, which will cause a memory leak.
The specific solution is :different virtual machines mount hugetblfs
into different directories.

Tracked-On:#2854
Signed-off-by: bing.li <bingx.li@intel.com>
Reviewed-by: Minggui Cao<minggui.cao@intel.com>
Acked-by: Yin Fengwei<fengwei.yin@intel.com>
2019-06-11 15:03:47 +08:00
Conghui Chen 765669ee35 dm: support VMs communication with virtio-console
Adding the feature of communication between VMs using virtio-console
based on appointed socket file. Not appointing the socket type will set
the socket type to be server in default.

Example:
Server: adding "-s 5,virtio-console,socket:console=/path/console.sock:server"
Client: adding "-s 6,virtio-console,socket:console=/path/console.sock:client"

Tracked-On: #3232
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-06 12:40:47 +08:00
Conghui Chen c0bffc2f58 dm: virtio: refine console options parse code
Refine the virtio-console options parse code, so that no need to pass
all the variables as parameters to the backend adding function.

Tracked-On: #3232
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-06 12:40:47 +08:00
Peter Fang ce6e663f6c OVMF release v1.1
- Cleanup unused and unsupported function of AcrnRtc
- Remove SMBIOS support
- Add ResetSystemLib for ACRN
- Disable BhyveFwCtlLib
- Disable COM2
- Avoid connecting all system drivers
- Speed up Ps2KeyboardDxe
- Created new Rtc driver and optimized RtcInit and RtcGetTime
- Initialize EmuVariable NV storage memory with varstore from ROM
- Switch to BasePciLibPciExpress
- Avoid exhaustive PCI bus scanning during PCI host bridge
  initialization
- Add support for ACRN platform initialization
- Add ACRN's Host Bridge Device ID

Tracked-On: #3226
Signed-off-by: Peter Fang <peter.fang@intel.com>
2019-06-06 12:11:59 +08:00
Vijay Dhanraj a4e28213c2 DM: handle SIGPIPE signal
Ignore SIGPIPE signal and handle the error directly when write()
function fails. this will help us to catch the write failure
rather than crashing the UOS.

PS: Observed that when acrnctl stop command was issued from
kata-runtime, UOS was crashing with SIGPIPE signal.

Tracked-On: #3190
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-03 09:17:01 +08:00
Vijay Dhanraj 19366458f8 DM: handle virtio-console writes when no socket backend is connected
When virtio-console is used as console port with socket backend,
guest kernel tries to hook it up with hvc console and sets it up.
It doesn't check if a client is connected and can result in ENOTCONN
with virtio-console backend being reset. This will prevent client
connection at a later point. To avoid this, ignore ENOTCONN error.

PS: For Kata, the runtime first launches VM and then proxy which acts
as a client connects to this socket. If this error is not handled,
proxy will never be able to connect as the backend itself will be reset.

Tracked-On: #3189
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-03 09:17:01 +08:00
Tw 857e6c0415 dm: passthrough: allow not page-aligned sized bar to be mapped
Some physical bar sizes are not page aligned, in order to support them,
we map a bigger region which is page aligned.

Tracked-On: #3181
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-06-03 09:14:32 +08:00
Jian Jun Chen b98096ea06 dm: pci: fix the MMIO regions overlap when getting bar size
PCI spec says that the procedure of sizing a BAR is as follows:
1) disable the decode via command register
2) save the original value of BAR register
3) write all-1 to the BAR register
4) read BAR register back, calculate the size
5) restore the original value to BAR register
6) re-enable the decode via command register

Some driver does not disable the decode of BAR register via the
command register before sizing a BAR. This will lead to a overlay
of the BAR addresses when trying to register the intermediate
BAR address via register_bar. A stateful variable sizing is used
to keep track of such kind of BAR address changes and workaroud
this violation.

Currently this issue is only found when audio device is passed
through to Windows 10 guest. When it is fixed in the Windows
audio driver, this patch should be reverted.

v1 -> v2:
- change the commit message to add the procedure of BAR sizing from
  PCI spec

Tracked-On: #2962
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-06-03 09:14:15 +08:00
Gao Junhao 286dd180a7 dm: virtio: bugfix for polling mode
In vxworks, virtio-console FE driver only initiate 2 virtqueues, but BE
creates 2+ virtqueues for it. So the rest of the virtqueues are not
initiated. vq->used->flags cannot be used directly without any
condition.

Tracked-On: #3203
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-31 12:32:08 +08:00
Jian Jun Chen 811d1fe93d dm: pci: update MMIO EPT mapping when update BAR address
For PCI passthrough device when guest OS updates the BAR address
the corresponding EPT mapping should be updated as well.

Tracked-On: #2962
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Signed-off-by: Liu Shuo A <shuo.a.liu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-30 14:19:14 +08:00
yuhong.tao@intel.com 50f50872e0 DM: Cleanup vmcfg
Removed the entire vmcfg feature, these changes are made:
1.Deleted devicemodel/vmcfg/
2.Deleted devicemodel/include/vmcfg.h
3.Cleanup vmcfg in devicemodel/Makefile

Tracked-On: #3192
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-05-29 14:07:45 +08:00
yuhong.tao@intel.com 7315515c7c DM: Cleanup vmcfg APIs usage for removing the entire vmcfg
Vmcfg is useless and should be removed. Before removing vmcfg code,
cleanup vmcfg APIs in core/main.c

Tracked-On: #3192
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-05-29 14:07:45 +08:00
Binbin Wu a3073175a6 dm: e820: reserve memory range for EPC resource
Reserved 128MB memory range for EPC resource in E820 table, starting
from 0x80000000.
Need to align the base address b/t DM and HV.
For hypervisor, the base address will be specified in epc field in
vm_configurations.c

Tracked-On: #3179
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-29 11:24:13 +08:00
ZhangYun 610ad0ced8 dm: update uos path in launch_hard_rt_vm.sh
Tracked-On: #3188
Signed-off-by: ZhangYun <yunx.zhang@intel.com>
2019-05-29 09:35:19 +08:00
Vijay Dhanraj 517707dee4 DM/HV: Increase VM name len
VM Name length is restricted to 32 characters. kata creates
a VM name with GUID added as a part of VM name making it around
80 characters. So increasing this size to 128.

v1->v2:
It turns out that MAX_VM_OS_NAME_LEN usage in DM and HV are for
different use cases. So removing the macro from acrn_common.h.
Definied macro MAX_VMNAME_LEN for DM purposes in dm.h. Retaining
original macron name MAX_VM_OS_NAME_LEN for HV purposes but defined
in vm_config.h.

Tracked-On: #3138
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-27 12:13:51 +08:00
Vijay Dhanraj f010f99d67 DM: Decouple and increase kernel boot args length
Currently, we use STR_LEN for all checking the size of all the
acrn-dm parameters. But some parameters like kernel boot args
can grow based on different needs. For example, when kata launches
guest VM using acrn, the kernel boot args increases by 256 bytes
(i.e 1024 +256).

Just increasing STR_LEN will unnecessarily increase allocations
for other acrn-dm parameters. So decoupling only boot_args
length and increasing it to 2048.

PS: If other parameters like ramdisk path, kernel path,
elf_path etc. don't need 1024 bytes, we can reduce STR_LEN
to 256 or 512 bytes.

Tracked-On: #3138
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-27 12:13:51 +08:00
Xiaoguang Wu b10ad4b311 DM USB: xHCI: refine the logic of CCS bit of PORTSC register
The CCS bit of PORTSC register should be set according to the mapped
native port connection status, use xdev->devices if equal NULL is not
enough due to devices only be clear in disable slot which can't reflect
the native connection state in some gaps.

Tracked-On: #3163
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-24 13:21:12 +08:00
Xiaoguang Wu ae066689bb DM USB: xHCI: re-implement the emulation of extented capabilities
There are many quirks in Intel xHCI implementation and it is very hard
to debug under Microsoft Windows OS, hence use ACRN xHCI extented
capabilities as the default setting.

Tracked-On: #3163
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-24 13:21:12 +08:00
wenlingz 5f9cd25324 Revert "DM: Get max vcpu per vm from HV instead of hardcode"
This reverts commit 356bf18491.
2019-05-24 13:02:36 +08:00
yliu79 8bca0b1ae9 DM: remove unused function mptable_add_oemtbl
Change-Id: Icf92fd5bbbfe935960dc47307822827092a46369
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 bd3f34e952 DM: remove unused function vm_get_device_fd
Change-Id: I9056838bbf150983c8011706d3d0a07aed043917
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 9224277b5e DM: remove unused function vm_setup_ptdev_msi
Change-Id: Ia62d4a75ef6074cfd4f5b271ab21ff9ed0a64f51
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 bb8584dd4a DM: remove unused function vm_apicid2vcpu
Change-Id: I3bb503058df8e0048370f6c1ab77f63aadf1eb57
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 ec924385ae DM: remove unused function vm_create_devmem
Change-Id: I1d6b56688e533a00a484548ed97fd1968f01041d
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 75ef7e8458 DM: remove unused function vm_set_lowmem_limit
Change-Id: I0f9ad089b8e72c7ecd9c83a9115727140c945c4f
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 683e2416b1 DM: remove unused function console_ptr_event
Change-Id: If8dc5ba21d172a6794d86b048d61d9ccfc28cab4
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 12f55d1389 DM: remove unused function console_key_event
Change-Id: I6ab81750757fd12929fd60c9d7fa92fd96c9520b
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 aacc6e5926 DM: remove unused function console_refresh
Change-Id: I7ad16ecf3325e012fd738f2774aec6d957efd678
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 2711e553ce DM: remove unused function console_fb_register
Change-Id: I334b83c0b0a69f705c11ff7017a96dc6875e5c9a
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 d19d0e26c6 DM: remove unused function gc_init
Change-Id: I91f498b9ae98002bc86b78fce2a0836c508b3945
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 43c01f8e26 DM: remove unused function console_init
Change-Id: I5c06a1dd057cea0edd364c846958074ee3df4987
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 e6360b9b7f DM: remove unused function gc_resize
Change-Id: I82504374fed44f08d92910d0d34a02337d844fd0
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 d153bb8664 DM: remove unused function gc_set_fbaddr
Change-Id: I005edc5f69fcd3b4969c7c7d75f633d2219acbe5
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 475c51e53a DM: remove unused function console_set_fbaddr
Change-Id: Ia0d96880a53a7564492ec4d7943b3040e32dd6e0
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 4e7703161e DM: remove unused function swtpm_reset_tpm_established_flag
Change-Id: I8253df84ef490418e37ac3d565dcdc7bb8123f3b
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 2a33d52ec6 DM: remove unused function vrtc_reset
Change-Id: If0dbd40cf54eb81ca4ced9acae273d291e99b25c
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 1a726ce010 DM: remove unused function vrtc_get_time
Change-Id: I2074295234f8cfaf5f325bfbacab9c86779653bf
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 8cb64cc71f DM: remove unused function vrtc_nvram_read
Change-Id: I0b8c42879256e53762aeb031f63fc043ae2d9128
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 dcd6d8b5a9 DM: remove unused function virtio_pci_modern_cfgread and virtio_pci_modern_cfgwrite
Change-Id: I3f362858956a642ae0de9ab36387e274fc939659
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 62f14bb11f DM: remove unused function virtio_dev_error
Change-Id: I6e94ab0286e73435429e2ccf971207c7d8ed6ef6
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
yliu79 2d6e6ca375 DM: remove unused function usb_native_is_ss_port
Change-Id: I7991560b40b936776e45f7b81fee085935eb6eae
Tracked-On: #3123
Signed-off-by: Ying Liu <ying2.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-24 11:51:00 +08:00
Arindam Roy 3d459dfddc DM: Fix minor issue of USB vendor ID
Provide a minor fix for following issue:
Emulated USB controller Vendor ID and Device ID are swapped.

Tracked-On: #3053
Signed-off-by: Arindam Roy <arindam.roy@intel.com>
Reviewed-by: Xu, Anthony <anthony.xu@intel.com>
2019-05-24 09:31:42 +08:00
Tw 321e4f1300 DM: add virtual hostbridge in launch script for RTVM
Hostbridge is necessary for passing kernel pci subsystem initialization
sanity check which is located in pci_sanity_check(). It will check
whether a host bridge exists.

BTW, set rtvm flag explicitly.

Tracked-On: #3152
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-05-23 14:07:05 +08:00
Wei Liu bb48a66b96 dm: refine the passthrough devices with dictionary
As vm config tool will override the passthrough devices if run on
different hw, and it will take a lot of work to search and
replace the passthrough device.
This patch refine the passthrough devices that tools to overwrite.

Tracked-On: #3127
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2019-05-17 11:06:31 +08:00
fuyongjie 49350634b1 DM: virtio-gpio: fixed static variable keeps increasing issue
virtio_gpio_ops variable type is static,so use "+=" will let
the value keep increasing when acrn-dm reset.

Tracked-On: #3118
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Signed-off-by: fuyongjie <fuyongjie@neusoft.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-05-15 15:20:28 +08:00
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