We will mark ioreq as COMPLETE in VHM via IC_NOTIFY_REQUEST_FINISH
ioctl. vm_notify_request_done can do it. So remove this one.
Tracked-On: #1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
VHM will provide a ioctl to clear all IO requests' status. This is
useful to handle ioreqs in VM normal reboot and emergency reboot.
Tracked-On: #1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Also remove the '\n' from the hugetlb's file name.
Tracked-On: #2133
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
The patch fix some string operations issues and also improve readability
of several snippet.
Tracked-On: #2133
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Discard the input/output data when open tty file. To avoid the
mevent callback is triggered immediately when the fd is added to
epoll.
Also update the uart_drain only read the data from tty file when
fifo has available space.
Tracked-On: #2159
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
As VIRTIO_CONFIG_S_NEEDS_RESET is not defined in standard virtio header
file on ubuntu, there will be compile issue. so add
VIRTIO_CONFIG_S_NEEDS_RESET to fix it.
Tracked-On: #2145
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Reuse linux common virtio header file and remove the repetitive
definition.
Tracked-On: #2145
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Physical NIC mac address is used for generate UOS mac address.
This patch uses a new parameters to pass this information
instead of vm name.
Tracked-On: #1987
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
S3 emulation is complicated and greatly dependent on system timing,
hence this patch changes log level for some important logs to help
online debugging (could output log by modifing launch_uos.sh and
without re-compiling)
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Now one macro is added to define the alignment requirement.
>#define __aligned(x) __attribute__((aligned(x)))
Some code uses the __aligned(x) to define the alignment while the other
code uses the original alignment definition.
So they are unified.
Tracked-On: projectacrn/acrn-hypervisor#2131
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Release the resource reqeusted during msix table init if error occurs.
Change the type of the second arg of deinit_msix_table from pci_vdev to ptdev,
to align with init_msix_table.
Tracked-On: #1782
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Currently, the emulation of pci msi/msix can be handled by hypervisor code.
The logic in dm passthru driver can be simplified.
This patch remaps msix table to usersapce in DM passthru driver.
1. The access to the msix table in passthru driver will be trapped, and emulated by hv code.
2. The access to the config space in passthru driver will be trapped, and emulated by hv code.
So dm passthru driver no longer needs to keep the whole logic of handling msi/msix.
No need to do msix table remapping in sos kernel.
After the patch, the msix table ioremap code in vhm_dev.c can be removed.
Tracked-On: #1782
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Support DISCARD command is meaningful when eMMC usage is high or
there are lots of remove operations. For example, when Guest
Android is running, there will be lots of files being created and
removed. However, virtio-blk BE does not support DISCARD command,
data remove operation in UOS will not trigger erase in eMMC. After
period of time, the eMMC will be consumed out, and erase must be
done by eMMC firmware before writing any new data. This causes the
eMMC performance decrease in the whole system (SOS and UOS).
To solve the problem, DISCARD should be supported in virtio-blk BE.
Tracked-On: #2011
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
To keep consistent with kernal code, change delete to discard.
Tracked-On: #2011
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Replace sscanf in device model hw directory
Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Replace strlen function with strnlen function in device-model
Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Replace function sprintf with snprintf in device model
Tracked-On: #2079
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This is an obvious bug, which releases memory but still access the
data on the released memory. It is risky operation, and may result
failing to do normal enumlation process. This patch is used to fix
it.
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
The USB S3 virtualization logic is complicated and heavily affected by system
timing. To make the debugging work easily, change related log level to facilitate
quick bug fixing.
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
When issue happen, we could identify which thread is impacted.
This could help stability issue debugging.
Tracked-On: #2037
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
irqfd only supports msix devices. In the current code a mevent is
added to poll the callfd from userspace to support intx devices.
This patch removes the support for non-msix devices since they are
not used in the current device model.
Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Teardown callback is provided when mevent_add is called and it is
used to free the virtio-net resources.
Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Teardown callback is provided when mevent_add is called. A ref_count
is added to virtio_console data structure. Teardown callback needs to
free the resources of the backend and when the ref_count of the
virtio_console is zero the whole virtio-console is freed.
Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Teardown callback is provided when mevent_add is called and it is
used to free the virtio-input resources.
Tracked-On: #1877
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
On Intel Apllo Lake platform, the VBus will drop after the SOC suspended,
hence during the SOS resuming process, there will be a disconnecting event
and a connecting event sent to each native USB device in order.
This patch will use new strategy for S3 resuming emultion.
1. The DM set PORTSC register to 'no device attached' state when S3
suspending started,
2. SOS resuming starts and do nothing for device disconnecting event,
3. 'Cache' device connecting event and don't report it to UOS,
4. UOS believe no device attached due to PORTSC register state and
begin to clear the resource allocated for the device before S3
suspending,
5. DM receives the Disable Slot command from UOS and report the 'cached'
device connecting event to UOS, hence trigger the emulation behavior
for the device.
The purpose of this strategy is to let UOS resuming proceed as quickly as
possible, which means the UI will be turned on quickly to user.
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
According to xHCI spec 5.4.1.1, this command hasn't ask to clear
PORTSC for R/S handling. So the PORTSC should always present the
physical usb bus status.
The old implementation changes the PORTSC according whether the
pci_xhci_dev_emu struct is allocated, it is not consistent with
spec and this patch is used to fix it.
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Comparing two USB devices' path is frequently used operation, abstract
it as an seperated function for convenience.
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This workaround will delay the UOS resuming for 5 seconds, this
behavior is not right and should be replaced by dynamic style.
Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
There are several KW issues which uninitialized variables
are used. This patch will fix those KW issues.
Signed-off-by: weideng <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
In USB mediator, sscanf, strtok and atoi API is banned, so replace them
with permitted API function.
Tracked-On: #1254
Signed-off-by: Yang Liang <liang3.yang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Always enforce data size when using BAR access functions.
Currently, the size serves as a hint to the BAR access functions and
these functions are expected to behave accordingly. Some of the access
functions, e.g. virtio ones, don't always truncate the data but expect
the caller to take care of the data size. This causes problems with
OVMF's virtio drivers during I/O instruction emulation because RAX can
contain junk bits that shouldn't be written to the device.
v1 -> v2:
- improve readability
Tracked-On: #1935
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Use '--ovmf <OVMF image location>' when launching acrn-dm.
Tracked-On: #1832
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Generic infrastructure for loading BIOS/ROM and providing EPT pages at
High BIOS region.
The size of High BIOS is rounded up to a multiple of 2MB.
v2 -> v3:
- refine mmap_hugetlbfs* to reduce code replication
v1 -> v2:
- make this code generic instead of OVMF-specific
Tracked-On: #1832
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This is preparation for the upcoming High BIOS work.
Tracked-On: #1832
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
A sample args file is added, which will be linked to /usr/share/acrn/conf/add/[vmname].args at integration time.
Because it is needed for AaaG one-key startup enabled build.
Tracked-On: #2040
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
The current vmcfg uses the default values in Kconfig when a previous .config
does not exist. This leads to additional complexity to silentoldconfig.py which
has different logic depending on the environment variable 'BOARD'. This also
blocks the effort to make the top-level Makefile recognize BOARD because any
environment variable set in the top-level Makefile cascades to the other
Makefiles, leading the work around above to fail.
This patch introduces a generic defconfig for vmcfg and simplifies
silentoldconfig.py to always fail when neither .config nor the specified
defconfig exists.
Tracked-On: #1995
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Physical NIC mac address is used for generate UOS mac address.
This patch uses a new parameters to pass this information
instead of vm name.
Tracked-On: #1987
Signed-off-by: Jie Deng <jie.deng@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
EV_MSC is configured as INPUT_PASS_TO_ALL in input driver. There is
a loop in the use case of virtio-input. They should not be forwarded
back to BE since they have already been sent to native driver before
sending to FE.
Tracked-On: #2006
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
To fix the issue that watchdog reset hang issue. At previous change,
we assume the reset comes from guest. But watchdog reset or dm killed
by signal is different. It's possible the vm_loop stick on ioreq
attaching.
The new fixing has two parts:
- fixing from kernel side to remove the race issue in ioreq attach,
req_complete_notify and client destory.
- Move the client destroy before waiting of vm_loop exit.
Tracked-On: #1986
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This patch adds the runC container config file, we will run acrn-dm
in runC container, and set acrn QoS parameters based on runC.
In the config file we mount SOS root directory to the container and
disable network/mount/ipc namespace.
Tracked-On: projectacrn/acrn-hypervisor#2020
Signed-off-by: Long Liu <long.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
After mutiple usb devices send enable slot commnad and get slot id each
other, address device setup flow is not sorted by slot id. According to
current design, it will casue assert failure. This patch takes off this
restriction.
Tracked-On: #2017
Signed-off-by: Yang Liang <liang3.yang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Pass teardown callback when add mevent in mei mediator code.
Which could avoid run_callback calling after the related data
structure is freed.
Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
There is one race issue between mevent callback (which is called
in mevent_dispatch thread) and mevent_delete (which could be called
in dev thread). And the callback is called after mevent_delete.
libevent have the exactly same issue. The issue is decripted here:
https://github.com/libevent/libevent/blob/master/whatsnew-2.1.txt
The fixing is:
We introduce a teardown callback to mevent and make sure there is
no race issue between callback and teardown call.
This patch updates the mevent API and the caller as well.
Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Peter, Thomas and Shuo raised one race issue in mevent_del. It
happens like following:
Thread mevent_dispatch Thread
mevent_delete_event
epoll_ctl_del
free(evp)
mevent_handle with freed evp
The fixing is adding sync between mevent_delete_event and
mevent_handle in mevent_dispatch.
Thread mevent_dispatch Thread
mevent_delete_event
add evp to del_list
notify mevent_dispatch
return
mevent_handle
Remove evp from del_list
Remove evp from epoll_fd
closefd()
free(evp)
Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>