Commit Graph

1290 Commits

Author SHA1 Message Date
Conghui 3dab043344 dm: bugfix for iothread
As the type of pthread_t is unsigned long, so the init value for it
should not be '-1'. When the tid is '-1', it will continue to call
pthread_kill/pthread_join. This is incorrect.

Tracked-On: #7960
Signed-off-by: Conghui <conghui.chen@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-08-10 22:33:34 +08:00
Chenli Wei 030b2f804c dm: fix the secure coding style violations
There was some secure coding style violations of virtio net and tmp,
this patch add some NULL check to fix these violations.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
2022-08-02 18:01:24 +08:00
Conghui 7d987f9b0f dm: virtio-block: support NO_NOTIFY
disable NOTIFY during getting requests from virtqueue. This will improve
the IO performance.

Tracked-On: #7940
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-08-02 11:14:54 +08:00
Conghui 1bf3cb61f5 dm: virtio-blk: enable support for iothread
The usage is:

-s <slot> virtio-blk,[iothread,]<filepath>

e.g  -s 3 virtio-blk,iothread,test.img

Tracked-On: #7940
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-08-02 11:14:54 +08:00
Conghui fa69f79e33 dm: add iothread support in virtio framework
Add ioeventfd and iothread to virtio framework. When a virtio device
claim to support iothread, virtio framework will register a ioeventfd
and add it to iothread's epoll. After that, the new notify will come
through the iothread instead of the vcpu thread. The notify handler will
be called to process the request.

Tracked-On: #7940
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-08-02 11:14:54 +08:00
Conghui 4fd0a1900a dm: support iothread
Supply a decidate thread, which can moniter a set of fds with epoll,
when the data is ready, call the corresponding callback.

This iothread will be created automatically with the first successful
call to iothread_add,  and will be destroyed in iothread_deinit if it
was created.

Note, currenlty only support one iothread.

Tracked-On: #7940
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-08-02 11:14:54 +08:00
Liu Long 49d6a909cd ACRN:DM: Correct vhost_ext_features network bit
Use the VHOST_NET_F_VIRTIO_NET_HDR in linux system header file,
and set the correct feature bit for Virtio net header.

Tracked-On: #7790
Signed-off-by: Liu Long <long.liu@linux.intel.com>
2022-07-27 07:57:29 +08:00
Liu Long 73c529a903 ACRN:DM: Free virtio_vsock struct resource in deinit function
Free the virtio_vsock struct resource in virtio vsock deinit function
in case memory leak.

Tracked-On: #7759
Signed-off-by: Liu Long <long.liu@linux.intel.com>
2022-07-27 07:57:29 +08:00
Liu Long 6e18d2bd8f ACRN: DM: Fix the vsock error info.
Replace the exclamation mark with period mark in debug info and fix
the Guest CID max value macro.

Tracked-On: #7456
Signed-off-by: Liu Long <long.liu@linux.intel.com>
2022-07-27 07:57:29 +08:00
Ziheng Li eb8bcb06b3 Update copyright year range in code headers
Modified the copyright year range in code, and corrected "int32_tel"
into "Intel" in two "hypervisor/include/debug/profiling.h" and
"hypervisor/include/debug/profiling_internal.h".

Tracked-On: #7559
Signed-off-by: Ziheng Li <ziheng.li@intel.com>
2022-07-15 11:48:35 +08:00
Shiqing Gao 59b6d7b404 dm: verify the "iasl" version
This patch does:
- define IASL_MIN_VER in the top-level Makefile and pass it Device Model
- verify the "iasl" version at run time
  if "iasl" version is older than IASL_MIN_VER, refuse to launch the
  post-launched VM and exit directly.

Tracked-On: #7880

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-07-13 14:01:01 +08:00
Shiqing Gao cc309bd973 dm: refine the detection of "iasl" utility
At run time (on the *target* machine), acrn-dm depends on "iasl" to build
the ACPI tables for post-launched VMs.

This patch does:
- remove the dependency on ASL_COMPILER, which would only be used at build time
- add a new acrn-dm parameter "--iasl <iasl_compiler_path>"
  If "--iasl <iasl_compiler_path>" is specified as the acrn-dm parameter,
  acrn-dm uses <iasl_compiler_path> as the path to the "iasl" compiler;
  otherwise, "which iasl" is used to detect the "iasl" compiler.

  If "iasl" is not found at run time, refuse to launch the post-launched VM
  and exit directly.

v2 -> v3:
 - use "strlen" rather than "strncmp" to check whether asl_compiler
   has been set or not

v1 -> v2:
 - remove "iasl_param" and "with_iasl_param" to simplify the logic

Tracked-On: #7880

Signed-off-by: Victor Sun <victor.sun@intel.com>
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-07-13 14:01:01 +08:00
Geoffroy Van Cutsem ff07ccae0f Makefile: remove old samples (Apollo Lake)
Remove sample files and launch scripts related to the Apollo Lake (APL)
platform since ACRN no longer supports it. Clean the Makefile as well to not
install these files on the target system.

Tracked-On: #6175
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-07-05 10:08:40 +08:00
Conghui 18af997373 dm: virtio-console: change STDIO BE attribute
Fix the log format problem in devicemodel when using virtio-console with
'stdio' configuration.
In virtio-console, it will change the STDIO's attributes, and will case
the log message after that not align.
e.g:
	for (i=0; i<3; i++)
		printf('test\n');

	The original output would be like this:

	test
	    test
	        test

	After add 'OPOST' to oflag of STDIO, the output would be like this:

	test
	test
	test

	(OPOST - Enable implementation-defined output processing)

Tracked-On: #7860
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-06-30 17:42:44 +08:00
Liu Long bd8c0de62b ACRN: DM: Fix the MSI mask and unmask bugs.
The patch fix many bugs about the pci msi capabilities.
 1. Fix the clear msi mask bit issues.
 2. Initialize the offset of pci capabilities this variable will used as
 the output of pci_emul_find_capability function.
 3. Replace 16-read with 32-read because both mask and pending are 32bit.
 4. Add mask and pending element in msicap struct and intialize the struct
 value to zero, because we need r/w mask and pending value.

Tracked-On: #7762
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-06-14 16:28:50 +08:00
Liu Long 038335367d DM: vsock: fix the memory leakage bug
Fix the memory leakage issue caused by incomplete deinit flow.

Tracked-On: #7759
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-06-14 15:10:05 +08:00
Liu Long b2d9112ed5 DM: Add endpoint index value check in doorbell write
Check max ep index in doorbell write function to avoid overwriting
the pci_xhci_dev_emu->eps[XHCI_MAX_ENDPOINTS].

Tracked-On: #7759
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-06-14 15:10:05 +08:00
Yifan Liu dc65edec35 dm: Coding style fix: variable initialization
Initialize cid variable in virtio_vhost_vsock_init.

Tracked-On: #7593
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2022-06-14 12:54:25 +08:00
Yifan Liu eafc5ff418 dm: Coding style fix: Handle failure of parsing /proc/iomem
In get_mmio_hpa_resource, although very unlikely, parsing
of /proc/iomem may fail. Handle the case of failure and exit early.

Tracked-On: #7593
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2022-06-14 12:54:25 +08:00
Sun Peng 38a275af26 dm: vdisplay: fix comment typos.
Fix some typos in output logs.

Tracked-On: #7747
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-06-14 10:23:14 +08:00
Yonghua Huang 195ff32054 dm: fix uninitialized variable issue in hpet_mmio_read
'data' maybe used uninitialized in function
 hpet_mmio_read() function.

Tracked-On: #7606
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2022-06-08 14:15:47 +08:00
Geoffroy Van Cutsem bb30301e23 Update TSC members and maintainers
Updates to the TSC members and maintainer list
* Update the Technical Steering Committee (TSC) members following the election
of Junjie Mao as the new chair
* Update Thomas Gleixner's email address since he joined Intel Corporation
* Delete the MAINTAINERS files in the 'hypervisor' and 'devicemodel' folders
  as they are obsolete and unused.

Tracked-On: #7706
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-06-08 14:14:27 +08:00
Liu Long 1cfcf464ca ACRN: xHCI: Check the value of Ring Segment Size
Flow Table 6-95 from xHCI spec, Ring Segment Size defines
the number of TRBs supported by the ring segment, valid
values for this field are 16 to 4096.

Tracked-On: #6981
Signed-off-by: Liu Long <long.liu@intel.com>
2022-06-06 11:52:35 +08:00
hangliu1 5acec55bc8 dm: Fix uninitialized variable in AHCI
tfd is one data field of FIS for AHCI, it is unacceptable if it is
random value, could cause AHCI data transport failure.

Acturally there is no chance the switch statement has the value other
than 0~3, since there is only 2 bit to deduce.

Add the initial value for tfd as ATA_S_ERROR, which is checked by
function ahci_write_fis_d2h afterwards, so guest driver could handle it well.

Tracked-On: #7679

Signed-off-by: hangliu1 <hang1.liu@linux.intel.com>
2022-06-02 19:02:06 +08:00
Sun Peng 7ee0421d33 dm: vdisplay: terminate acrn-dm process when SDL init failed
Virtual display is component which based on native window system.
This feature depended phisical monitor connected and graphic driver in
SOS running correctly. If these dependencies fail, it is a fatal error
for virtual display. We have to terminate the device model to let user
fix runtime environment issue for graphics.

Tracked-On: #7672
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
2022-06-02 17:00:32 +08:00
Liu Long 5f06a2f58e ACRN: DM: Fix the vsock Guest Cid overflow issue
The vsock cid type is u64, redefine the cid type to u64, and use
dm_strtoul API replace dm_strtoi.

Tracked-On: #7456
Signed-off-by: Liu Long <long.liu@linux.intel.com>
2022-05-31 11:22:43 +08:00
Sun Peng 8e263385c5 dm: vdisplay: add modes supported by Windows virtio-gpu driver
Add 1280x1024@75, 1024x768@75, 1600x1200@60, 1600x900@60 modes.

Tracked-On: #7507
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-05-23 13:18:43 +08:00
Sun Peng a4b08b7694 dm: vdisplay: Remove 1280x720 resolution
1280x720 resolution will crash IDD of windows guest. To simplise, just
remove this mode.

Tracked-On: #7507
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-05-23 13:18:43 +08:00
Sun Peng f24f10b4b9 dm: vdisplay: Remove modes filter in EDID generation
All the modes that vdisplay supported should be reported to driver,
then driver should select the modes which report to OS.

Tracked-On: #7507
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-05-23 13:18:43 +08:00
Liu Long 49426147aa ACRN: DM: Fix the virtio negotiated features bug.
The virtio feature bits is 64bits but the access will be split
as two times 32bits access. This patch fixes the bug which overwrites
another side 32bits, and causes feature bits are lost.

Tracked-On: #7456
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-05-12 16:15:24 +08:00
Liu Long 46e41390b5 ACRN: DM: Implement the vhost vsock
This patch supports the user space logic of vhost vsock which
is majorly for its initialization phase.

Tracked-On: #7456
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-05-12 16:15:24 +08:00
Liu Long 231f986bd9 ACRN: DM: Expose the vhost kernel ioctrl API
The patch expose the vhost kernel ioctrl API and remove the virtio_net
operation functions to the virtio_net code module.

Tracked-On: #7456
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-05-12 16:15:24 +08:00
Helmut Buchsbaum 78f702ef8c Use libdrm library for drm access
Use needed constants from libderm instead of directly using
kernel UAPI.

Tracked-On: #6688
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2022-05-10 09:20:14 +08:00
Helmut Buchsbaum 7637e53963 dm: Remove dependency on libuuid
Since any uuid relevant action directly uses Linux kernel UAPI
(linux/uuid.h) the use of libuuid is not required.

Tracked-On: #6688
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2022-05-10 09:20:14 +08:00
Zhao Yakui 3921812885 ACRN:DM:VGPU: Add more standard modes for EDID block
EDID uses the bytes of 38-53 to support up to 8 standard modes. And it is
based on the mechanism: Byte 0 defines the xres / 8 - 31 and byte 1 defines
the aspect_ratio/refresh_rate.
But now it uses the incorrect logic in course of adding standard mode, which
causes that no standard mode is added in EDID block.

Fix it and add another two standard modes so that the guest_vm can parse
more modes from EDID.

Tracked-On: #7376

Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-05-07 10:08:46 +08:00
Zhao Yakui 4972d29c2d ACRN:DM:VGPU: Fix the incorrect offset for EDID detailed_timing_block
The EDID uses the bytes of 54-125 to define the four detailed_timing_blocks.
But the static offset is used to update the DTB. This will cause that
the incorrect offset is used for DTB if the edid_generate is called several
times.

Tracked-On: #7376

Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-05-07 10:08:46 +08:00
Chenli Wei 513eafd6f0 dm: optimize the sub parameter of "-s" compatibility
This patch checks the change of "-s" sub parameters, which was
obsoleted or moved and the print some warnings msg or show the new
format.

The following obsoleted parameters are covered:

-s ,pci-gvt
-s ,virtio-hdcp
-s ,npk
-s ,virtio-coreu
--mac_seed

Reviewed-by: VanCutsem Geoffroy <geoffroy.vancutsem@intel.com>
Signed-off-by: Chenli Wei <chenli.wei@intel.com>
2022-05-05 15:03:34 +08:00
Fei Li 79442cbc96 dm: acpi: refine CPU Definition Blocks name
For all Definition Blocks in ACPI Namespace, their name are a fixed 32 bits.
This patch refine CPU Definition Blocks name to support more than 10 CPUs
for a guest.

Tracked-On: #7387
Signed-off-by: Fei Li <fei1.li@intel.com>
2022-04-29 16:53:16 +08:00
Zhao Yakui 373dac68ef ACRN:VGPU: Virtio_gpu_init calls the vdpy_init before vdpy_get_display_info
Now vdpy_get_display_info/get_edid is called before vdpy_init.
This is incorrect. They should be called after setting up the
connection with vdisplay.

Tracked-On: #7376
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-28 09:41:06 +08:00
Zhao Yakui e3b7f736d7 ACRN:VGPU: Add the missing initialization of vdisplay info
Now some fileds are not initialized, which causes that ACRN-DM doesn't
handle the request of VIRTIO_GPU_CMD_GET_DISPLAY_INFO and
VIRTIO_GPU_CMD_GET_EDID.

Tracked-On: #7376
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-28 09:41:06 +08:00
Zhao Yakui 402565f222 ACRN:VGPU: Fix the incorrect logic of fetching EDID
The virtio_gpu in guest_vm will try to fetch the EDID to query
the supported resolution. Guest vm will send the cmd of
VIRTIO_GPU_CMD_GET_EDID and receive the response of VIRTIO_GPU_RESP_OK_EDID.
Now acrn-dm has some issues in course of handlding EDID request: Incorrect
resp type, the incorrect response. This will cause that the guest_vm fails
to fetch the EDID.

Tracked-On: #7376
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-28 09:41:06 +08:00
Chenli Wei a0678c82bb dm: optimize the parameter compatibility
This patch checks the obsoleted parameters and print some warnings
instead of exiting the acrn-dm directly. The following obsoleted
parameters are covered:

-i, --ioc_node
-G, --gvtargs
-Y, --mptgen
--vsbl
--part_info
--pm_by_vuart
--pm_notify_channel

Tracked-On: #6690
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: Chenli Wei <chenli.wei@intel.com>
2022-04-24 10:25:09 +08:00
Zhao Yakui 599962fe71 ACRN:DM:VGPU: Rename thread_name for dedicated rendering thread
Otherwise it will use the "acrn_dm" as the thread_name, which is not
convenient to check the cpu_usage of rendering_thread.

Tracked-On: #7337
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-21 16:35:15 +08:00
Zhao Yakui 0873575a03 ACRN:DM:VGPU: Free the memory after creating udmabuf
In course of creating the udmabuf, udmabuf_create_list is allocated and
passed to kernel. After the dmabuf is returned, it is not used
any more. Need to free it otherwises it will cause the memory leak.

Tracked-On: #7337
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-21 16:35:15 +08:00
Zhao Yakui 8b7767e643 ACRN:DM:VGPU: Fix the incorrect use after free
It still tries to access the gpu->vdpy_handel after the gpu
is free. This is incorrect.

Tracked-On: #7337
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-21 16:35:15 +08:00
Zhao Yakui 2a7a269313 ACRN:DM:VDISPLAY:Fix the possible access after free
When virtio-gpu tries to submit the framebuffer based on
VIRTIO_GPU_CMD_2D, one pixman_image will be created. When the
sdl rendering_thread is terminated, the pixman_image will be 
released. But its pointer is set to NULL. In the next reboot,
its access in vdpy_surface_set is incorrect.  

Tracked-On: #7337
Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-21 16:35:15 +08:00
Zhao Yakui de3e0946bc ACRN:DM:VGPU: Add some checks to ignore multi-thread op
Now all the 3D ops are handled in one dedicated thread. As 3D ops are
not safe in multi-thread env, some checks are added so that it can indicate
that it is not in the expected code path.

Tracked-On: #7296
Acked-by: Wang Yu1 <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-19 18:30:06 +08:00
Zhao Yakui a555658484 ACRN:DM: Fix the memory_leak of vga_context in virtio_gpu_deinit
Otherwise the memory related with vga_context is leaked.

v1->v2: Use the pthread_join instead of usleep to wait for
the termination of vga_thread.

Tracked-On: #7296
Acked-by: Wang Yu1 <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-19 18:30:06 +08:00
Zhao Yakui 2e9773ed55 ACRN:DM: Avoid calling surface_set in course of virtio_gpu_reset
This is not needed as it is reconfigured in course of vga_thread_loop.
At the same time it is not thread-safe as the 3D api is involved
in vdpy_surface_set.

v2->v3: move the initialization of vga_surface width/height into
vga_thread.

Tracked-On: #7296
Acked-by: Wang Yu1 <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-19 18:30:06 +08:00
Zhao Yakui c73773c130 ACRN:DM: Avoid creating multi threads for vga_thread
In order to support the VGA op, one vga_thread is created. But
in course of virtio_gpu_reset, it will also create one vga_thread.
This is incorrect.

v1->v2: the thread_id of vga_thread is treated as read-only after
the thread is created.
        One thread_status based on atomic type indicates the life_cycle
of vga_thread.

v2->v3: Add the vga_thread_mtx in course of changing life_cycle of vga_thread

Tracked-On: #7296
Acked-by: Wang Yu1 <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-19 18:30:06 +08:00