Commit Graph

1235 Commits

Author SHA1 Message Date
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 c19b2bed18 ACRN:DM: Add the support of blob_buffer from guest_vm
Now Virtio-gpu FE is using the below cmds to submit the framebuffer that
needs to be displayed.
   VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D
   VIRTIO_GPU_CMD_SET_SCANOUT
   VIRTIO_GPU_CMD_FLUSH

This will introduce twice copy. In order to optimize the twice copy, the below
cmds are added and the virtio-gpu BE can use the dma-buf sharing.
   VIRTIO_GPU_CMD_CREATE_BLOB
   VIRTIO_GPU_CMD_SET_SCANOUT_BLOB
   VIRTIO_GPU_CMD_FLUSH

V2->V3: Remove the inlined header file of devicemodel/include/public/udmabuf.h
to avoid the license issue

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
Zhao Yakui a46b0058d8 ACRN:DM: Use the memfd to allocate anonymous hugetlb file
The ACRN-DM uses the explicit hugetlb file to allocate the memory
for guest and the 2M/1G hugetlb can be used. This is based on mounting
hugetlb filesystem.
Now the Linux provides one flexbile memfd mechanism to allocate the memory
and this can make it possible to create the udmabuf for sharing. And the
memfd still can be based on Hugetlb 1G/2M policy. This can bring the below
benefits besides the 1G/2M hugetlb support.
a. memfd is based on anonymous file
b. possible dmabuf mechanism

v2->v3: After completing the mmap for memfd, it will call the ftruncate to
set the desired size and then add the F_SEAL_SEAL flag.

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 3bf11d9285 ACRN:DM: Check the alignment of mem_size
Now the memory region is aligned down to 2M if 2M hugetlb is supported.
Maybe some contents are dropped if it is not aligned. 

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
Peter Fang 4fc4b84304 OVMF release v3.0
- VGA interface of virtio-gpu adapter support
- Ovmf:ACRN: Fix the building error
- acrn: fix how to get memory below 4G

Tracked-On: #7231
Signed-off-by: Peter Fang <peter.fang@intel.com>
2022-03-31 09:06:34 +08:00
Zhao Yakui 473c5819ea ACRN:DM: Add extra path header definition to support cross-compiler building
The virtio-gpu needs to include some system header files.
In order to support the cross-compiler building, the header
path is added.

Tracked-On: #7210

Reported-by: Naveen Kumar Saine <naveen.kumar.saini@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2022-03-29 11:16:40 +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 fae4286cb3 dm: virtio-gpu: 2D mode support
Implement 2D mode of virtio-gpu adapter which can transfer outputs
from guest vm framebuffer and store them to host 2D scanout buffers.
These 2D scanout buffer can be shown by calling vdpy_surface_set/update
API provided device/include/vdisplay.h.

Virtio-gpu 2D commands calling sequence:
  1) VIRTIO_GPU_CMD_GET_EDID
  2) VIRTIO_GPU_CMD_GET_DISPLAY_INFO
  3) VIRTIO_GPU_CMD_RESOURCE_CREATE_2D
  4) VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING
  5) VIRTIO_GPU_CMD_SET_SCANOUT
  6) VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D
  7) VIRTIO_GPU_CMD_RESOURCE_FLUSH

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
Minggui Cao 1bc2921c27 Revert "Revert "dm: set PMU_PT flag for CPU ...""
This reverts commit 6750d5a277.

the bug is root caused and fixed, so recovery the original patch.

Tracked-On: #6966
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2022-03-28 12:00:01 +08:00
Yonghua Huang d8c0d5eebb dm: update virtio-i2c bus counter when device is deinit
i2c bus counter 'acpi_i2c_adapter_num' shall be updated
 when virtio-i2c device is de-initialized, else in user VM
 reboot case, this global counter will not be reset and
 keep the value last user VM boot, which is not expected
 and cause iasl(building ACPI data) program crash finally
 because the i2c device name space overflow.

Tracked-On: #7208
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2022-03-23 10:37:52 +08:00
Chenli Wei b9431b8da4 dm: remove the assume of virtio-net device name
Now, the DM assumes the device name entered by user is dependent on
the type.

For example, the device of tap type is named tap_TAAG, this patch
remove the above assumption.

User could set any name, no matter the code of DM or actually created,
it is represented by user input.

Tracked-On: #6690
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: Chenli Wei<chenli.wei@linux.intel.com>
2022-03-22 11:33:09 +08:00
Yuanyuan Zhao 8f9a47c30f dm: add warning for `-A` param
DM dynamic param '-A' has been removed.
For compability, add a warning for `-A` instead of terminate the launch
process.

Tracked-On:#6690
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
2022-03-21 14:06:02 +08:00
Minggui Cao 6750d5a277 Revert "dm: set PMU_PT flag for CPU core partition VM"
This reverts commit 811992ee2b.

There could be some conflict with current configure tool. will fix it
later.

Tracked-On: #6966
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2022-03-14 20:18:08 +08:00
Minggui Cao 811992ee2b dm: set PMU_PT flag for CPU core partition VM
for CPU core partition VM, like RTVM, set PMU passthrough
flag for vtune/perf to run in guest VM.

Tracked-On: #6966
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2022-03-10 14:34:33 +08:00
Tw d1e3e8d633 dm/tools: compatible with openssl3.0
HMAC_*, MD5_* and SHA256_* are deprecated since openssl3.0, replace them with the corresponding equivalents.

Tracked-On: #6743
Signed-off-by: Tw <wei.tan@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-03-08 17:39:47 +08:00
dongshen ce7b38ee04 dm: fixed a bug where mptable failed to wake up CPU1# when adding acpi=off into User VM cmdline
Previous commit introduced the "use physical APIC IDs as vLAPIC IDs for VMs" change,
but it didn't update the apic_id in mptable. Changed the mptable code to also
set apic_id to physical APIC ID to fix the bug

Tracked-On: #7146
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2022-03-02 11:22:31 +08:00
Zhao Yakui eb9a58c70e ACRN:DM: Set the desired state to inject PCI legacy intx
When the virtio-XXX pci devices fall back to legacy PCI intx,
the pci_irq_assert is called to inject the interrupt and then
the pci_irq_deassert is used to mark the completion of PCI interrupt.
Currently the HV vIOAPIC uses the pin_state for the interrupt injection
of legacy PCI intx. In such case it will fail to inject the PCI legacy
intx and the guest system fails to be booted when adding the boot option
of "pci=nomsi".

PCI legacy INTx usually use active low level trigger mode as it is Open-Drain
state and allows multitple interrupt signals to share a single line.
https://wiki.osdev.org/PCI_Local_Bus_Signals
In such case DM needs to set the correct state for the PCI device so that the
HV vIOAPIC can help to inject the PCI legacy intx.

BTW: When the MSI/MSIX is used for PCI device, it uses another mechanism
to inject the interrupt. It is harmless to configure the initial state.

Tracked-On: #7124
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-02-21 15:34:01 +08:00
Yonghua Huang b4386566ef dm: fix mevent mutex deadlock issue
'mevent_lmutex' is initialized as default type,
 while attempting to recursively lock on this
 kind of mutext results in undefined behaviour.

 Recursively lock on 'mevent_lmutex' can be detected
 in mevent thread when user tries to trigger system
 reset from user VM, in this case, user VM reboot hang.

 The backtrace for this issue:
  #1 in mevent_qlock () at core/mevent.c:93
  #2 in mevent_delete_even at core/mevent.c:357
    ===>Recursively LOCK
  #3 in mevent_delete_close at core/mevent.c:387
  #4 in acrn_timer_deinit at core/timer.c:106
  #5 in virtio_reset_dev at hw/pci/virtio/virtio.c:171
  #6 in virtio_console_reset at
     hw/pci/virtio/virtio_console.c:196
  #7 in virtio_console_destroy at
    hw/pci/virtio/virtio_console.c:1015
  #8 in virtio_console_teardown_backend at
    hw/pci/virtio/virtio_console.c:1042
  #9 in mevent_drain_del_list () at
    core/mevent.c:348 ===> 1st LOCK
  #10 in mevent_dispatch () at core/mevent.c:472
  #11 in main at core/main.c:1110

  So the root cause is:
  mevent_mutex lock is recursively locked by mevent thread
  itself (#9 for this first lock and #2 for recursively lock),
  which is not allowed for mutex with default attribute.

  This patch changes the mutex type of 'mevent_lmutex'
  from default to "PTHREAD_MUTEX_RECURSIVE", because
  recrusively lock shall be allowed as user of mevent
  may call mevent functions (where mutex lock maybe required)
  in teardown callbacks.

Tracked-On: #7133
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2022-02-21 14:23:03 +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
Xiangyang Wu b448567784 DM: add command handler for command monitor
The command handler is to implement handlers for each command,
currently, two handler is implemented for command monitor:
user_vm_destroy_handler: the handler is for user VM destroy command,
which shuts down to standard post-launched user VM forcefully.
user_vm_blkrescan_handler: the handler is for user VM blkrescan
command, which rescan virtio-blk device to revalidate and update
the backend file for user VM.

v1--v2:
	Update log message format.
	Generate JSON format ack message using libcjson lib APIs.
v2-->v3:
	Update ACK message to {"ack": 0} or {"ack": -1}

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 a31bd7bb0d DM: add command module for command monitor
The command module provides interfaces to find a command
intance, register handler for specified command, dispatch
command and invoke related handler.
find_command: find a command instance by name.
register_command_handler: register the handler for one
command instance.
dispatch_command_handlers: dispatch the command and invoke
registered handler.

v1-->v2:
	Only support single handler for one command instance.
v2-->v3:
	Remove command id.
	Add error check to avoid regiter handler to command
	instance which has handler.
	Update the second parameter type of register_command_handler
	to avoid unnecessary type conversion.

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 26fdfc6a30 DM: add socket module for command monitor
The socket module is to provide interfaces below, the unix domain
socket can be created by command monitor for the communication
between DM instance and libvirt daemon or kata container:
init_socket: allocate a new socket instance according to socket path
deinit_socket: free a socket instance
open_socket: open one unix domain socket server, initialize a
socket, create one thread to listen to client, another thread to
poll message from client.
close_socket: close one unix domain socket server
find_socket_client: find socket client instance according to fd
write_socket_char: send message through unix domain socket server

v1--v2:
	Update some log message format and copyright format.
v2-->v3:
	Update SOCKET_MAX_CLIENT to 1H since the socket instance of
	command monitor only have one client (libvirt or kata container).

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
Yuanyuan Zhao 47ff99fd64 dm: rtvm enable lapic_pt automatically
Enable `lapic_pt` automatically for rtvm for better performance.

Reserve `--lapic_pt` for future use. If VM is not in realtime mode,
`--lapic_pt` will cause a warning.

Tracked-On: #6690
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-02-17 19:13:49 +08:00
Yonghua Huang 13ce55ef4f dm: fix memory leakage issue in disk_logger.c
In function probe_disk_log_file(), handler 'dir'
 returned by opendir() is not released before
 function return and results in memory leakage.

Tracked-On: #7098
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2022-02-10 15:26:22 +08:00
Yonghua Huang 4b0590415d dm: disable TCC strict CPU affinity check
By default, pCPU is allowed to request software SRAM buffer
 from given region in TCC buffer driver only if this pCPU is
 set in the target region's CPU affinity configuration.

 This check shall be disabled for software SRAM virtualization
 usage in ACRN service VM, because software SRAM buffers are
 requested by ACRN DM on behalf of user VM, but ACRN DM and
 user VM may run on different CPUs while the target software
 SRAM region may be configured only for pCPUs that user VM runs on.

 This patch turns off such affinity check in TCC driver when
 initializing vSSRAM for user VM.

Tracked-On: #7010
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2022-02-09 15:44:58 +08:00
Chenli Wei df9bab9aca dm: refine the mac check logic for virtio-net
The current mac detection logic only check whether there are parameters
after tap opt. Don't care whether the parameter is MAC or not, then
mac_provided will be set to 1, which will disable the mac_seed setting
when using sub parameters

This patch will check opt and fix the above issue.

Tracked-On: #6690
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
2022-02-08 10:51:39 +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
Yonghua Huang e0a01a12d9 dm: remove dependency on vm_get_config() API
GET_PLATFORM_INFO IOCTL syscall will not be supported
 from ACRN HSM driver, while vm_get_config() API depends
 on it hence shall be removed.

 Without vm_get_config(), vm_get_cpu_affinity_dm() is used
 to get guest CPU bitmask.

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 8a44067f8b dm: use lapic id to set cpu affinity.
Cpu affinty was set by pcpu id which can't be obtained
explictly by user. Use lapic id instead which can be easily
read from `/proc/cpuinfo` as `apicid`.

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
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
Chenli Wei 6d49f0f26a dm:add UID parameter for acpidev_pt
Now the acpidev_pt module only use the hid to check the device,it can't
work well if there are more then one instance.

So this patch add UID to identify same type device to fix these issue.

Tracked-On: #6690
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
2022-01-28 11:34:31 +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
Chenli Wei 8594d15d0c dm:change mac_seed to virtio-net sub-parameter
As a parameter of acrn-dm,the mac_seed is only used for virtio-net.

So this patch change it to the sub-parameter of virtio-net.

Tracked-On: #6690
Acked-by: Yu1 Wang <yu1.wang@intel.com>
Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
2022-01-27 16:39:49 +08:00
Chenli Wei d755205c8d dm:change virtio-net parameters for cmdline
Remove device name requirement for “tap” and "vmnet", change the
parameter format like:
"-s 4,virtio-net,tap/vmnet=dev_name".

Tracked-On: #6690
Acked-by: Yu1 Wang <yu1.wang@intel.com>
Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
2022-01-27 16:39:49 +08:00
Yuanyuan Zhao 940b78d42f dm: remove short version of dm dynamic param `-W`
Rename '--virtio_msix' to '--virtio_msi' for this param
means 'force virtio to use singel-vector MSI'.

`-W` is the short version of `--virtio_msi`. But it's
confusing that `-W` and `--virtio_msi` are irrelevant literally.
So remove the short version `W` to prompt user friendliness.

Tracked-On: #6690
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-01-24 09:07:39 -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
Yuanyuan Zhao 9f0fe154d0 dm: remove dynamic param '-A'
Dynamic parameter '-A' means to generate acpi table in dm.
Few scenario use dm without '-A'. So remove it, and always
generate apci table automatically.

Tracked-On: #6690
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2022-01-21 13:19:38 +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 5ff532b08c dm: add RTCT memory hierarchy entries to vRTCT
Add TCC native memory hierarchy entries  to vRTCT:
   - wrap one function to get TCC RTCT data.
   - Add memory hierarchy entries from TCC
     RTCT to vRTCT.

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 216c295cb4 dm: init vRTCT header information
This patch initializes below entries in vRTCT:
  - Hardcode ACPI header
  - Hardcode RTCT compatibility entry, support RTCT v2 only
    for ACRN user VMs.

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 9e68aa759a dm: setup EPT mapping for vSSRAM buffers
Add EPT mapping for all L2 & L3 vSSRAM buffers
  for user VM.

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