Commit Graph

418 Commits

Author SHA1 Message Date
Jiaqing Zhao 7bfbdf04b8 doc: remove '@return None' for void functions
doxygen will warn that documented return type is found for functions
that does not return anything in 1.9.4 or later versions. 'None' is
not a special keyword in doxyge, it will recognize it as description
to the return value that does not exist in void functions.

Tracked-On: #8425
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2023-08-03 14:56:29 -07:00
Jiaqing Zhao 75b031b63c dm: pci: read dsm size from igd device for igd passthrough
Currently the DSM (Data of Stolen Memory) size was hardcoded to 64M in
ACRN, meaning that users must set "DVMT Pre-Allocated" to 64M in order
to make IGD passthrough (GVT-d) to work. This patch reads the BIOS-
configured memory size from GGC (GMCH Graphics Control, 0x50) register
and passthrough corresponding area to guest.

Tracked-On: #8432
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
2023-07-27 12:23:12 +08:00
Jiaqing Zhao 3bbf99acbd dm: pci: add device table for igd passthrough
The register index and data format of BDSM (Base Data of Stolen Memory)
of Intel integrated graphics is changed in GPU Gen 11. Currently ACRN
uses a long device list for Gen11+ devices. This patch introduces a new
device allowlist for IGD passthrough in igd_pciids.h, covering IGD
device ids from Skylake, and handles passthrough by its generation.

If a device is not listed, it will be treated as a gen 11 device and a
warning will be printed, developers should add the new device to the
list if it is verified to work.

Tracked-On: #8432
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
2023-07-27 12:23:12 +08:00
Conghui a715a3222b asyncio: refine the setup ioctl
Remove the common interface for sbuf setup, as it is not accept by
kernel side. Instead, use dedicate setup function for asyncio to init
its sbuf.

Tracked-On: #8209
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-11-25 10:43:34 +08:00
Liu Long 0caf1ac0de ACRN:DM: Fix the vhost register kick fd issue.
Add the new parameter for register ioevent function, let the vhost
vq and viothread vq can share the register ioevent common API.

Tracked-On: #8323
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Reviewed-by: Conghui <conghui.chen@intel.com>
2022-11-21 11:18:23 +08:00
Conghui 0ec9aaea6f dm: support asyncio in ioeventfd
Add a new flag in ioeventfd ioctl to support asyncio. After that, the IO
request will be processed in asyncio path by kernel and hypervisor.

Tracked-On: #8209
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-09-27 16:10:15 +08:00
Conghui 0f599e8d56 dm: add a new page for asyncio
asyncio is a new mechanism in ACRN, which is special for these devices
which need high IO performance. ACRN hypervisor would process the IO
request from User VM in an async mode.

Just like the original IOReq shared page, the devicemodel also create a
page for fastio requests. As the asyncio use the ioeventfd, so the
reuqests are handled in kernel, devicemodel only need to provide the
page.

Tracked-On: #8209
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-09-27 16:10:15 +08:00
Zhao Yakui 64ecf193e4 ACRN:DM:PCI: Load rom_file and map it into PCI ROMbar
PCI ROM is the firmware specific to PCI device and it is provided by
the device vendor. The PCI rom resides in 0x30 offset of PCI config space.
This can be used to check whether the PCI rom exists. And when it exists,
it can load the firmware from the addr that is obtained from ROM bar addr.

For the user-vm, it will try to load the rom_file for the given PCI device and
enable the VM to access the firmware that is defined in rom_file.

BTW: The emulated rom_file is converted from efi image by using EfiRom. It has
no dependency on the ROM bar of physical PCI devices. Of course if the physical
PCI devices supports the ROM bar, the rom_file can also be dumped from the PCI
rom.

Now this is limited to PCI display device.

V2->V3: Add the function of pci_load_rombar/pci_release_rombar to handle the
	rombar in course of passthrough_init/deinit.

Tracked-On: #8175
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2022-09-23 18:12:01 +08:00
Zhao Yakui 270aaf82d8 ACRN:DM:PCI: Add the support of allocating resource for PCI ROM bar
Now the device model only supports the 0..5 PCI bar for PCI/PCIE devices.
This tries to allocate the PCI_MEM32 resource for PCI ROM bar.

V1->V2: Use the PCI_ROMBAR as bar index and PCIBAR_ROM bar type when calling
the pci_emul_alloc_bar to allocate the guest physical addr for PCI ROM bar.
And it will allocate the resource from PCIBAR_MEM32 region.

V2->V3: Add more comments that describes the parameter of pci_emul_alloc_bar.

Tracked-On: #8175
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2022-09-23 18:12:01 +08:00
Conghui 91cc0d5bf8 dm: iothread: fix bug in iothread handler
Fix the bug in iothread handler, the event should be read out so that the
next epoll_wait not return directly as the fd can still readable.

Tracked-On: #8181
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-09-21 12:29:07 +08:00
Conghui b083341bd9 dm: change virtio-i2c from legacy to modern device
Change virtio-i2c from legacy to modern device according to virtio spec v1.2.

Tracked-On: #8055
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-08-25 14:50:24 +08:00
Zhao Yakui 0606247b02 ACRN:DM:VGPU: Calibrate the offset in dmabuf/pixman_image to display the scanout_window
Sometimes the virtio_gpu in guest_vm doesn't pass the zero coord_x/y for the
displayed framebuffer. In such case the offset should be calibrated for pixman_image/dmabuf
so that it can display the image from the correct image.

Tracked-On: #7988
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Peng Sun <peng.p.sun@linux.intel.com>
2022-08-15 14:44:47 +08:00
Zhao Yakui 6407de302c ACRN:DM:VDisplay: vdpy_init connection returns the supported number of vScreen
Vdisplay module will create the gui_window (vScreen) based on the virtio-gpu
parameter. When virtio-gpu device tries to establish the connection with
vdisplay module, it will return the supported number of vScreen.
Then the virtio-gpu device can initialize the correct info for the guest_vm.

BTW: The number is fixed to 1.

Tracked-On: #7988
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Peng Sun <peng.p.sun@linux.intel.com>
2022-08-15 14:44:47 +08:00
Zhao Yakui ad67215d4b ACRN:DM:VDISPLAY: Refine display API to support multi scanout_window
Currenly it can support only one display_win. When virtio-gpu wants to display
the framebuffer from Guest_vm, it will render it into the default win. In order
to support multi-window, the scanout_id is added for display API.
After display API is refined, the vdisplay and virtio-gpu can support the multi-win
independently.

BTW: Now the scanout_id is not implemented in vdisplay module and the virtio-gpu always
passes the zero. It will be implemeneted in the later patches.

Tracked-On: #7988
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Peng Sun <peng.p.sun@linux.intel.com>
2022-08-15 14:44:47 +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 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
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
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
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
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 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 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
Liu Long e347320787 ACRN:DM: Add pci msi per-vector masking capable
Add msi per-vector masking capable and emulate msi mask
pending mechanism in DM.

Tracked-On: #7265
Signed-off-by: Liu Long <long.liu@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-04-11 13:50:21 +08:00
Sun Peng c61d41da27 dm: Update license info of types.h
Add license info to devicemodel/include/types.h

Tracked-On: #7248
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
2022-04-08 13:54:47 +08:00
Sun Peng bfde6182d2 dm: virtio-gpu: update copyright and license
Add license information to virtio_gpu.c
Fix some grammar issues.

Tracked-On: #7241
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-04-08 13:54:47 +08:00
Geoffroy Van Cutsem 8b16be9185 Remove "All rights reserved" string headers
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).

Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-04-06 13:21:02 +08:00
Zhao Yakui 34bfaa71f6 ACRN:DM: Export BLOB feature to guest
The DMABuf sharing is based on the BLOB feature. This will
check the attribute of system memory for guest_vm and udmabuf.list_limit
parameter. If it meets with the requirement, export the BLOB feature
so that the FE driver in guest_vm can send the blob cmd.
VIRTIO_GPU_CMD_CREATE_BLOB:
VIRTIO_GPU_CMD_SET_SCANOUT_BLOB:
VIRTIO_GPU_CMD_SET_FLUSH(BLOB)

Tracked-On: #7210

Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-01 11:40:43 +08:00
Zhao Yakui f9aa6f754a ACRN:DM: Add Texture based on DMAbuf to support dmabuf_sharing rendering
Now the Opengl rendering is used implicitly in SDL backend. But sometimes
it needs to create the texture explicitly based on DMABuf so that it can
render the framebuffer submitted from virtio-gpu.

Tracked-On: #7210

Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-01 11:40:43 +08:00
Zhao Yakui 3645a9557d ACRN:DM: Add one API to query the memfd/offset for the given GPA
After using the memfd to allocate memory for guest vm, it needs to
query the offset in memfd for the given GPA. In order to search the
memfd/offset, the added memory_region from memfd needs to be kept in
one arrary.

Tracked-On: #7210

Acked-by: Wang Yu <yu1.wang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-04-01 11:40:43 +08:00
Sun, Peng 1ed96bfbf8 dm: virtio-gpu: VGA compability support
Legacy VGA & VBE interface as a common interface is supported by
many legacy and modern OS. Many installer of OS distribution use
this interface to display the GUI of installer when setup a refresh
new installation on bare-metal. Besides, Windows OS always use this
interface to display it's BSOD, recovery mode & safe mode GUI. It
is need because Windows don't include virtio-gpu driver as their
in-box driver, VGA interface will be used before the virtio-gpu
driver been installed.
To be compatiable with the PCI bar layout of legacy VGA, the layout
is refined to meet with the requirement of legacy VGA and modern
virtio-gpu.

BAR0: VGA Framebuffer memory, 16 MB in size.
BAR2: MMIO Space
  [0x0000~0x03ff] EDID data blob
  [0x0400~0x041f] VGA ioports registers
  [0x0500~0x0516] bochs display interface registers
  [0x1000~0x17ff] Virtio common configuration registers
  [0x1800~0x1fff] Virtio ISR state registers
  [0x2000~0x2fff] Virtio device configuration registers
  [0x3000~0x3fff] Virtio notification registers
BAR4: MSI/MSI-X
BAR5: Virtio port io

Tracked-On: #7210
Signed-off-by: Sun Peng <peng.p.sun@linux.intel.com>
Reviewed-by: Zhao, yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-28 15:26:20 +08:00
Sun, Peng f2cfa761ae dm: virtio-gpu: cursor surpport
Hardware cursor emulation of virtio-gpu video adapter. Guest vm can
show its own cursor in virtual display, not share the cursor with
service vm. It also accelerated by SDL(OpenGL ES 2.0 backend) API
with hardware acceleration based on the GPU hardware own by service
vm.

Tracked-On: #7210
Signed-off-by: Sun, Peng <peng.p.sun@linux.intel.com>
Reviewed-by: Zhao, yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-28 15:26:20 +08:00
Sun, Peng eba0820bc7 dm: virtio-gpu: EDID emulation of virtual monitor
Extended display identification data(EDID) is a data to store
display timings which are supported by ACRN virtual monitor.
Virtio-gpu FE driver will request it to config crtc for display
resolutions.

Tracked-On: #7210
Signed-off-by: Sun, Peng <peng.p.sun@linux.intel.com>
Reviewed-by: Zhao, yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-28 15:26:20 +08:00
Sun, Peng bca6464e9f dm: virtio-gpu: virtual display support
ACRN virtual monitor shown as a GUI system window of service vm.
It can display graphic outputs of guest vm which is stored in
service vm's buffers by virtio-gpu. Display operation is accelerated
by Intel GPU PF(SRIOV) device with SDL(OpenGL ES 2.0 backend) API.
This provides one generic display solution. When the virtio-gpu is
added, it will firstly try to setup the connection to graphics system
and then display the framebuffer from the guest vm in the created
window region.

Tracked-On: #7210
Signed-off-by: Sun, Peng <peng.p.sun@linux.intel.com>
Reviewed-by: Zhao, yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-28 15:26:20 +08:00
Sun, Peng 37a4cdc2e0 dm: virtio-gpu: basic framework
Virtio-gpu is a virtio based graphic adapter. It supports 2D mode
which can transfer the guest vm's framebuffer into service vm's
buffers for displaying. It can co-work with Intel GPU VF(SRIOV)
device and provide thransport for the accelerated contents. With
this, guest vm can benefit Intel GPU hardware to accelerate media
coding, 3D rendering and compute.

Tracked-On: #7210
Signed-off-by: Sun, Peng <peng.p.sun@linux.intel.com>
Reviewed-by: Zhao, yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-28 15:26:20 +08:00
Wen Qian a5a005f129 dm: add checks of ioctl return value for ACRN userspace
The current code does not always check the return value of function
ioctl called in ACRN userspace, and lack of error message printing
to help debug.

This code fixes it by checking the return value of ioctl, and adding
function errormsg to return a string describing of the error code.

Tracked-On: #7029
Signed-off-by: Wen Qian <qian.wen@intel.com>
Signed-off-by: Li Fei <fei1.li@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-02-21 09:25:50 +08:00
Xiangyang Wu cc2efdc049 DM: add DM parameter for command monitor
Libvirt or kata container needs to send some commands
(such as VM destory command) to the DM instance of User VM
through command monitor socket, they will specify the socket
path and pass this path name to DM instance through DM parameter.

In this patch, add new DM parameter (cmd_monitor) to get socket
path from libvirt or kata container. If cmd_monitor is specified,
it initialize and deinitialize command monitor in DM main loop.

v2-->v3:
	Include command monitor initialization and deinitialization.

Tracked-On: #5921

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-02-18 18:33:52 +08:00
Xiangyang Wu 02e94b1537 DM: add new monitor module
This monitor module is to initialize socket intance, register
handlers to handle command from socket message, close socket,
free socket instance:
init_cmd_monitor: initialize socket intance and register handlers
to handle command.
deinit_cmd_monitor: close socket and free socket instance.

In this patch DM makefile is updated to build command monitor.

v1--v2:
	Update socket path and update log message format.
	Parse JSON format command message using libcjson lib APIs.
v2-->v3:
	Use socket path length MACRO.
	Update JSON format command message to {"command": "xxx"}.

Tracked-On: #5921

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-02-18 18:33:52 +08:00
Yonghua Huang dd2d1a5610 dm: remove vm_get_config() API
This API depends on GET_PLATFORM_INFO ioctl command,
 which will not be supported from ACRN HSM anymore.

 This patch removes the definition of it and
 also cleans related data structure.

Tracked-On: #6690
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-01-28 14:54:28 +08:00
Yuanyuan Zhao c5537ec4d4 dm: get lapic id from madt
The GET_PLATFORM_INFO will be removed from hypervisor. The acrn-dm can
only refer to Service VM's resources from now, all the resources out of
Service VM are not awared by acrn-dm. The original info got from
GET_PLATFORM_INFO needs to changed to Service VM's perspective like lapic id.

The pcpu_id is the index of lapic instance in MADT table. This patch
parses the Service VM's MADT table to convert the pcpu_id to lapic_id instead
of GET_PLATFORM_INFO.

Tracked-On: #6690
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-01-28 14:21:22 +08:00
Minggui Cao 483b7b1280 dm: fix: TSN in multi-hostbridge could crash
fix bug: if PTM-CAP device, like TSN in multi-hostbridge could cause
acrn-dm crash.

original PTM PCI code has not handled multi-hostbridge case, and just
handled hostbridge (00:00.0) case.

this patch calls PCI access API to handle PTM-CAP device/bridge
(root port) structure, to avoid scan PCI hierarchical.

Tracked-On: #7045
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2022-01-28 11:10:44 +08:00
Wen Qian ace5ef44e8 dm: fix the bug that infinite calls to vq_getchain()
The current code would cause infinite calls to vq_getchain()
because that:
  - error check of vq_getchain() return value is missing.
  - virtqueue misunderstand that there are avaliable descripters
    even though the idx of avail ring is invalid.

This patch fixes it by checking validity of the return of
vq_getchain() and jump out of the loop for invalid return value.
This patch alse add validity check in judgment of avaliable
descriptor, and check if the diff between idx of avail ring and
the last idx is greater than size of this queue.

Tracked-On: #7038
Signed-off-by: Wen Qian <qian.wen@intel.com>
Signed-off-by: Li Fei <fei1.li@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
2022-01-21 14:17:16 +08:00
Yonghua Huang 6bf70e3e35 dm: add ssram support for user VM
Hook ssram init && de-init functions to vdev
 devices lifecycle management:

 1) initialize ssram when vdev devices
    are initialized.

 2) de-initialize ssram when vdev devices
    are reset or destroyed.

 notes:
 ssram configuration data can be released only when
 user VM shutdown, hence it can't be done in deinit_vssram().

  - VM reboot:
    do deinit_vssram() only.

  - VM shutdown:
    do both deinit_vssram() and clean_vssram_config().

Tracked-On: #7010
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
2022-01-10 13:34:27 +08:00
Yonghua Huang 7aae9807b3 dm: add RTCT SSRAM entries from vSSRAM buffers
add all L2 & L3 cache buffers to RTCT entries:
   - SSRAM WAY_MASK entry, cache ways bitmask indicates
     the cache ways used by specific cache buffer.

   -  SSRAM region entry, support format V2 only.

Tracked-On: #7010
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
2022-01-10 13:34:27 +08:00
Yonghua Huang bc746b9118 dm: initialize vSSRAM buffers
This patch figures out the guest cache hierarchy:
  - calculate the cache hierarchy parameters, including
    cache thread sharing number and inclusiveness of LLC.

  - define and initialize data structure to describe
    L2 & L3 cache buffers, these buffers will be mapped
    to user VM as ssram regions.

  - add some utility functions.

  - complete the implementation of function
    'create_ssram_rtct_entries()', though most functions
    inside are not implemented yet.

Tracked-On: #7010
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu1 Wang <yu1.wang@intel.com>
2022-01-10 13:34:27 +08:00