Commit Graph

184 Commits

Author SHA1 Message Date
Sun Peng 31a9525fa8 dm: ioc: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

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

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

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

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-10 09:33:25 +08:00
Yonghua Huang 07ed6841f5 dm:Remove deprecated terms
- remove usages of maste/slave:

Tracked-On: #5249
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2020-09-01 09:30:08 +08:00
Li Fei1 f13d5c25b6 dm: mmio_dev: add mmio device pass through support
We could add MMIO device pass through by two ways:
a) If the MMIO device only has MMIO regions and no ACPI Table touched, using
"--mmiodev_pt MMIO_regions",
b) If the MMIO device touches ACPI Table, using "--acpidev_pt HID"

Now only support TPM2 MSFT0101 MMIO device pass through through launch script
using "--acpidev_pt MSFT0101". When we want to pass through the TPM2 deivce,
we would not allow to emulate the vTPM2 at the same time. This is becuase
the ACRN-DM emulate the TPM2 as MSFT0101 too. Otherwise, the VM can't boot.

Besides, we could only support one TPM2 device PT and one MMIO device PT.
For TPM2 device PT, the MMIO resources are hard-coded. For the MMIO device PT,
we could pass through the MMIO resources on the cmdline.

ToDo:
1. We may use HID to discover the MMIO regions and ACPI Table instaed of
hard-coded.
2. To identify a MMIO device only by MMIO regions.
3. To allocate virtual MMIO regions in a reserved guest MMIO regions.

Tracked-On: #5053
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2020-07-23 20:13:20 +08:00
Li Fei1 80c7da8f1c hv: vioapic: expose ioapic to guest unconditionally
Some OSes assume the platform must have the IOAPIC. For example:
Linux Kernel allocates IRQ force from GSI (0 if there's no PIC and IOAPIC) on x86.
And it thinks IRQ 0 is an architecture special IRQ, not for device driver. As a
result, the device driver may goes wrong if the allocated IRQ is 0 for RTVM.

This patch expose vIOAPIC to RTVM with LAPIC passthru even though the RTVM can't
use IOAPIC, it servers as a place holder to fullfil the guest assumption.

After vIOAPIC has exposed to guest unconditionally, the 'ready' field could be
removed since we do vIOAPIC initialization for each guest.

Tracked-On: #4691
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-07-10 19:33:46 +08:00
Helmut Buchsbaum 884e9fc911 Revert "dm: acpi: add PSDS table in ACPI table"
This reverts commit 59e2de4805.

Since PSDS table format does not meet the expectations on all boards
providing a PSDS, such as e.g. Kontron COMe-mAL10 based boards, remove
exposure of PSDS table for now.

Tracked-On: #4846
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2020-05-29 09:03:52 +08:00
Mingqiang Chi a59205f6a2 dm:use acrn-dm logger function instread of fprintf
use acrn-dm logger function instread of fprintf,
this helps the stability testing log capture.

Tracked-On: #4098
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Cao Minggui <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-11-14 15:34:04 +08:00
Mingqiang Chi 5375a1613b dm:use acrn-dm logger function instread of printf
Use acrn-dm logger function instread of printf,
this helps the stability testing log capture.

Tracked-On: #4098
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Cao Minggui <minggui.cao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-11-14 15:34:04 +08:00
Binbin Wu dea2e25f41 dm: hw: fix the license of cmos_io.c
Fix the license of cmos_io.c to BSD-3-Clause

Tracked-On: #4032
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2019-11-08 16:42:54 +08:00
Gao Junhao 9143e56336 dm: update ACPI with latest ASL standard
The device model generating ACPI table use the old ASL
standard(version:20190816), then the iasl in clearlinux(version:31360)
is 20191018, it can't disassemble the ACPI table compiled by old
standard.

Tracked-On: #3933
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Fengwei Yin <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-10-25 15:12:00 +08:00
Yonghua Huang e7ef57a9f1 dm: fix mutex lock issue in tpm_rbc.c
In function crb_reg_write() in tpm_rbc.c
 'tpm_vdev->request_mutex' will potentially kept
 in locked state after crb_reg_write() returns.

Tracked-On: #3825
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Yadong Qi <yadong.qi@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-10-18 15:36:18 +08:00
Xiaoguang Wu e9211514e7 DM USB: modify disconnecting logic to support Windows 10
The Windows 10 feeds back quicker than Linux OS when error occured
due to device disconnecting, it will quickly reset the xHCI controller
before the DM starts to emulate disconnect event and it may cause some
unexpected errors such as crash.

This patch will do one more check when error happens, if the error
is induced by device disconnecting, the DM will not report error and
just wait until the disconnect event is reported to the guest. This
change could produce the correct hehavior as we expected.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-26 11:29:22 +08:00
Xiaoguang Wu 06781b37e9 DM USB: dynamically allocate block count for struct usb_xfer
The block count of the struct usb_xfer is hard coded by the macro
USB_MAX_XFER_BLOCKS (1024), it wastes memory if 1024 blocks are
allocated for low speed transfer such as control transfer or interrupt
transfer. This patch introduces a new method to allocate different
number of blocks according to different endpoint type.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-26 11:29:22 +08:00
Xiaoguang Wu 1352eca224 DM USB: introduce helper functions: index_inc and index_valid
Introduce helper functions to make code shorter and cleaner.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-26 11:29:22 +08:00
Xiaoguang Wu d58a766556 DM USB: re-implement the data block process logic
In Windows OS, there are many non-data blocks (EVENT DATA) during the USB
data transfer process, which is very different from the Linux conterpart.
To support both OS, the data processing logic is changed with the help of
newly introduced enum usb_block_type.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-26 11:29:22 +08:00
Xiaoguang Wu 236c23e418 DM USB: introduce enum type usb_block_type
In the process of USB data transfer, there three kinds of data blocks:
a. Non data block, which contains some control information;
b. Partial data block, which contains part of a large data chunk;
c. Full data block, which contains a complete data chunk.

In previous implementation, the differences mentioned above are described
by the usb_block::chained. But the 'chained' is concept in the xHCI area
and should not appear in the USB layer. This patch introduces enum type
usb_block_type to replace the 'chained' field in struct usb_block.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-26 11:29:22 +08:00
Xiaoguang Wu 7445e404a8 DM USB: code clean: change some names of functions and variables
Some names of functions and variables are long and not exact, this
patch is used to change them, no logic code are affected. The
changing included:

usb_data_xfer -> usb_xfer
usb_data_xfer_block -> usb_block
usb_xfer_blk_stat -> usb_block_stat
usb_data_xfer_append -> usb_block_append
USB_XFER_BLK_* -> USB_BLOCK_*

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-26 11:29:22 +08:00
Minggui Cao 00401a1e78 DM: separate pty vuart operation from IOC
for pty vuart operation will be commonly used by other module,
like pm-vuart: control UOS power off through vuart.

Tracked-On: #3564
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2019-09-11 16:43:22 +08:00
Xiaoguang Wu be0a4b692b DM USB: fix enumeration related issues
The patch fixes enumeration related issues introduced by commit 'fc3d19'.

Tracked-On: #3612
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-09-03 12:22:46 +08:00
Xiaoguang Wu fc3d19bee4 DM USB: fix potential crash risk due to null pointer
Fix potential risk to crash due to null pointer.

Tracked-On: #3612
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-08-26 14:17:49 +08:00
Xiaoguang Wu 55a5876eba DM USB: xHCI: workaround for USB SSD which supports UAS protocol
The USB mediator doesn't support USB Attached SCSI (UAS) protocol
due to no proper implementation for USB Stream. This patch will
use USB Bulk transfer to workaround until formal implentation for
UAS is ready.

Tracked-On: #3486
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-08-01 09:28:01 +08:00
Xiaoguang Wu 0e2cfd2dee DM USB: add native info in control transfer logging code
Add native bus and port information in the control transfer logging code.

Tracked-On: #3486
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-08-01 09:28:01 +08:00
Tianhua Sun 493ddefd47 dm: fix pointer not checked for null before use
this patch fix null pointer access issues.

Tracked-On: #3434
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
2019-07-30 16:36:13 +08:00
Xiaoguang Wu 5686898291 DM USB: xHCI: change log for convenience of debugging
Not change code logic, just modify some logging code.

Tracked-On: #3401
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-07-12 17:04:44 +08:00
Tianhua Sun d8b752c4ee dm: fix variable argument list read without ending with va_end
va_end() was not getting called under certain condition
after the va_start() function call taking the va_list.

Tracked-On: #3396
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-12 09:41:15 +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
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 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
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
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
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 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
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
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 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
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
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
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
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