Commit Graph

1149 Commits

Author SHA1 Message Date
Yonghua Huang d92c4bd840 dm: fix potential NULL pointer access in virtio_console.c
"port->cb" in 'virtio_console_notify_tx()'
 function maybe NULL when malicious inputs
 are injected from virtio frondend in guest.

Tracked-On: #6388
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-08-13 10:52:29 +08:00
Fei Li f81b39225c HV: refine acrn_mmiodev data structure
1. add a name field to indicate what the MMIO Device is.
2. add two more MMIO resource to the acrn_mmiodev data structure.

Tracked-On: #6366
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Signed-off-by: Fei Li <fei1.li@intel.com>
2021-08-11 14:45:55 +08:00
Li Fei1 8ef2eedba4 dm: mitigate reset attack
When a platform reboots or shuts down, the contents of RAM are not immediately
lost but begins to decay. During this period, there is a short timeframe during
which an attacker can turn the platform back on to boot into a program that
dumps the contents of memory (e.g., cold boot attacks). Encryption keys and
other secrets can be easily compromised through this method.

We already erasing the guest memory data when the guest is shut down normally.
However, if the guest is shut down abnormally, the contents of RAM may still
there. This patch mitigate this kind reset attack for a DM launched VM by
erasing the guest memory data by the guest has been created.

Tracked-On: #6061
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2021-08-10 15:36:49 +08:00
liu hang1 d07bd78b13 Makefile:add targz-pkg entry in Makefile
User could use make targz-pkg command to generate tar package in
build directory,which could help user simplify the process
of installing acrn hypervisor in target board. user need to copy the
tarball package to target board,and extract it to "/" directory.

Tracked-On: #6355
Signed-off-by: liu hang1 <hang1.liu@intel.com>
Reviewed-by: VanCutsem, Geoffroy <geoffroy.vancutsem@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-08-09 11:52:27 +08:00
Shuo A Liu 7947b4dae8 doc: Adapt documents to new HSM driver
Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu b218544872 dm: Remove hardcode vm_config size from vm_get_config()
vm_config size can be calced by platform_info.sw.max_vms *
platform_info.sw.vm_config_size.

Change vm_get_config() to call IOCTL ACRN_IOCTL_GET_PLATFORM_INFO
twice, first to get platform_info, second to get the vm_configs
content.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 07381888d3 dm: Use the new HSM eventfd ioctls
IC_EVENT_IOEVENTFD		->	ACRN_IOCTL_IOEVENTFD
IC_EVENT_IRQFD			->	ACRN_IOCTL_IRQFD

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 6e0b12180c hv: dm: Use new power management data structures
struct cpu_px_data		->	struct acrn_pstate_data
struct cpu_cx_data		->	struct acrn_cstate_data
enum pm_cmd_type		->	enum acrn_pm_cmd_type
struct acpi_generic_address	->	struct acrn_acpi_generic_address
cpu_cx_data			->	acrn_cstate_data
cpu_px_data			->	acrn_pstate_data

IC_PM_GET_CPU_STATE		->	ACRN_IOCTL_PM_GET_CPU_STATE

PMCMD_GET_PX_CNT		->	ACRN_PMCMD_GET_PX_CNT
PMCMD_GET_CX_CNT		->	ACRN_PMCMD_GET_CX_CNT
PMCMD_GET_PX_DATA		->	ACRN_PMCMD_GET_PX_DATA
PMCMD_GET_CX_DATA		->	ACRN_PMCMD_GET_CX_DATA

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 98c80d75b8 hv: dm: Use new virtual device management ioctls
IC_ADD_HV_VDEV		->	ACRN_IOCTL_CREATE_VDEV
IC_REMOVE_HV_VDEV	->	ACRN_IOCTL_DESTROY_VDEV
struct acrn_emul_dev	->	struct acrn_vdev

Also, move struct acrn_vdev to acrn_common.h as this structure is used
by both DM and HV.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 9e7abbb38c dm: Use new MMIO device passthrough management ioctls
IC_ASSIGN_MMIODEV	->	ACRN_IOCTL_ASSIGN_MMIODEV
IC_DEASSIGN_MMIODEV	->	ACRN_IOCTL_DEASSIGN_MMIODEV

struct acrn_mmiodev has slight change. Move struct acrn_mmiodev into
acrn_common.h because it is used by both DM and HV.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 3625eb7a99 hv: dm: Use new pci device passthrough management ioctls
IC_ASSIGN_PCIDEV		->	ACRN_IOCTL_ASSIGN_PCIDEV
IC_DEASSIGN_PCIDEV		->	ACRN_IOCTL_DEASSIGN_PCIDEV
QUIRK_PTDEV			->	ACRN_PTDEV_QUIRK_ASSIGN
struct acrn_assign_pcidev	->	struct acrn_pcidev

Move struct acrn_pcidev into acrn_common.h because it is used by both
DM and HV.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 9d67745037 dm: Use new ptdev interrupt management ioctls
IC_SET_PTDEV_INTR_INFO	 ->	ACRN_IOCTL_SET_PTDEV_INTR
IC_RESET_PTDEV_INTR_INFO ->	ACRN_IOCTL_RESET_PTDEV_INTR
struct ic_ptdev_irq	 ->	struct acrn_ptdev_irq
IRQ_INTX		 ->	ACRN_PTDEV_IRQ_INTX
IRQ_MSI			 ->	ACRN_PTDEV_IRQ_MSI

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 7e01d90b87 dm: Use new memory management ioctls
struct vm_memmap	->	struct acrn_vm_memmap
VM_MEMMAP_SYSMEM	->	ACRN_MEMMAP_RAM
VM_MMIO			->	ACRN_MEMMAP_MMIO
PROT_ALL		->	ACRN_MEM_ACCESS_RWX

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 9c910bae44 hv: dm: Use new I/O request data structures
struct vhm_request		->	struct acrn_io_request
union vhm_request_buffer	->	struct acrn_io_request_buffer
struct pio_request		->	struct acrn_pio_request
struct mmio_request		->	struct acrn_mmio_request
struct ioreq_notify		->	struct acrn_ioreq_notify

VHM_REQ_PIO_INVAL		->	IOREQ_PIO_INVAL
VHM_REQ_MMIO_INVAL		->	IOREQ_MMIO_INVAL
REQ_PORTIO			->	ACRN_IOREQ_TYPE_PORTIO
REQ_MMIO			->	ACRN_IOREQ_TYPE_MMIO
REQ_PCICFG			->	ACRN_IOREQ_TYPE_PCICFG
REQ_WP				->	ACRN_IOREQ_TYPE_WP

REQUEST_READ			->	ACRN_IOREQ_DIR_READ
REQUEST_WRITE			->	ACRN_IOREQ_DIR_WRITE
REQ_STATE_PROCESSING		->	ACRN_IOREQ_STATE_PROCESSING
REQ_STATE_PENDING		->	ACRN_IOREQ_STATE_PENDING
REQ_STATE_COMPLETE		->	ACRN_IOREQ_STATE_COMPLETE
REQ_STATE_FREE			->	ACRN_IOREQ_STATE_FREE

IC_CREATE_IOREQ_CLIENT		->	ACRN_IOCTL_CREATE_IOREQ_CLIENT
IC_DESTROY_IOREQ_CLIENT		->	ACRN_IOCTL_DESTROY_IOREQ_CLIENT
IC_ATTACH_IOREQ_CLIENT		->	ACRN_IOCTL_ATTACH_IOREQ_CLIENT
IC_NOTIFY_REQUEST_FINISH	->	ACRN_IOCTL_NOTIFY_REQUEST_FINISH
IC_CLEAR_VM_IOREQ		->	ACRN_IOCTL_CLEAR_VM_IOREQ
HYPERVISOR_CALLBACK_VHM_VECTOR	->	HYPERVISOR_CALLBACK_HSM_VECTOR

arch_fire_vhm_interrupt()	->	arch_fire_hsm_interrupt()
get_vhm_notification_vector()	->	get_hsm_notification_vector()
set_vhm_notification_vector()	->	set_hsm_notification_vector()
acrn_vhm_notification_vector	->	acrn_hsm_notification_vector
get_vhm_req_state()		->	get_io_req_state()
set_vhm_req_state()		->	set_io_req_state()

Below structures have slight difference with former ones.

  struct acrn_ioreq_notify
  strcut acrn_io_request

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 3c66ba7ef5 dm: Use new interrupt management ioctls
IC_INJECT_MSI		->	ACRN_IOCTL_INJECT_MSI
IC_SET_IRQLINE		->	ACRN_IOCTL_SET_IRQLINE
IC_VM_INTR_MONITOR	->	ACRN_IOCTL_VM_INTR_MONITOR

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 107cae316a hv: dm: Use new ioctl ACRN_IOCTL_SET_VCPU_REGS
struct acrn_set_vcpu_regs	->	struct acrn_vcpu_regs
struct acrn_vcpu_regs		->	struct acrn_regs
IC_SET_VCPU_REGS		->	ACRN_IOCTL_SET_VCPU_REGS

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu f476ca55ab hv: dm: Use new VM management ioctls
IC_CREATE_VM		->	ACRN_IOCTL_CREATE_VM
IC_DESTROY_VM		->	ACRN_IOCTL_DESTROY_VM
IC_START_VM		->	ACRN_IOCTL_START_VM
IC_PAUSE_VM		->	ACRN_IOCTL_PAUSE_VM
IC_RESET_VM		->	ACRN_IOCTL_RESET_VM

struct acrn_create_vm	->	struct acrn_vm_creation

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 3deb973b7a dm: Use new ioctl ACRN_IOCTL_GET_PLATFORM_INFO
IC_GET_PLATFORM_INFO	->	ACRN_IOCTL_GET_PLATFORM_INFO
struct acrn_vm_config	->	struct acrn_vm_config_header(DM only)
struct platform_info	->	struct acrn_platform_info

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 82fa2d6355 dm: Rename vhm_ioctl_defs.h to hsm_ioctl_defs.h
Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 5a8bfff7a4 dm: return value 0 of vm_create_ioreq_client is valid
Negative return value of vm_create_ioreq_client is invalid. 0 is valid.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 42989f753e dm: Remove header vmm.h
vmm.h has some unused definitions.

Keep the useful definitions and delete vmm.h

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 21e095dda0 dm: Remove unused vm_create_vcpu() interface
The hypervisor creates vCPUs for a User VM in VM creation interface. The
vm_create_vcpu() interface is not needed anymore.

Remove vm_create_vcpu() from acrn-dm.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-15 11:53:54 +08:00
Shuo A Liu 6ae5f8388e dm: Remove the API version check
Interface version is not recommended in Linux kernel community. Please
check Documentation/driver-api/ioctl.rst for reasons.

Remove the unused API version check from acrn-dm.

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-15 11:53:54 +08:00
Tao Yuhong ad53894fdb DM: TPM: tpm passthrough device must use fixed base GPA
The TPM driver will access some mmio registers using absolute address,
That means TPM base GPA must use same HPA value, when passthough it to VM

Tracked-On: #6126
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-07-05 13:18:29 +08:00
Tao Yuhong a82020839a DM: TPM2: Fix remove hard code GPA base miss control register info
CRB_REGS_CTRL_REQ is offset of control register to TPM mmio base,
need use the address to generate TPM2 acpi table

Tracked-On: #6126
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-07-05 13:18:29 +08:00
Sun Peng 28509b61c9 dm: Add PCI IDS for EHL/TGL/ADL in GPU passthrough
Add PCI IDS for ElkhartLake/TigerLake/AlderLake in GPU DSM and OpRegion
passthrough.

Tracked-On: #6270
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-02 09:50:05 +08:00
Shuo A Liu a65e01ae95 dm: Reset virtio device before release
With virtio polling mode enabled, a timer is running in the virtio
backend service. And the timer will also be triggered if its frondend
driver didn't do the device reset in shutdown. A freed virtio device
will be accessed in the polling timer handler.

Do the virtio reset() callback specifically to clear the polling timer
before the free.

Tracked-On: #6147
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-02 09:12:42 +08:00
Rong Liu 6684bcdaa1 dm: get native rootport's max payload
Get and save native root port's max payload in dev cap register in
vrp_config data structure which will be used to configure vrp's max
payload by hv.

Tracked-On: #5915

Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2021-06-15 08:53:53 +08:00
Liu Long 211a961e18 DM: xHCI: Check trb pointer before use it
The trb pointer may be NULL when get the address from user space, add
the pointer check before use the trb.

Tracked-On: #6172
Signed-off-by: Liu Long <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-06-11 09:30:51 +08:00
Yonghua Huang ccf606bded dm: remove redundant null check in unregister_mem_init
return value 'err' of mmio_rb_lookup() being 0 ensures
  'entry' is not NULL, hence checking it before 'free(entry)'
  is unnecessary.

Tracked-On: #6157
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-06-09 14:29:03 +08:00
Yonghua Huang 067cf8aa2c dm: fix memory leakage risk in create_and_inject_vrtct
Reading native RTCT failure induces leakage of
 memory pointered by 'buf'.

Tracked-On: #6157
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-06-08 15:33:19 +08:00
Yonghua Huang 154fe59531 dm: validate inputs in vq_endchains
inputs shall be validated to avoid NULL pointer access.

Tracked-On: #6129
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-06-08 10:00:38 +08:00
Yonghua Huang d0426fd249 dm: add RTCT v2 support for guest
The latest version of RTCT specification is version 2.

 This patch is to add RTCT v2 support for virtual RTCT
 of guest.

Tracked-On: #6020
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-06-01 10:41:51 +08:00
Yonghua Huang 69808297b1 dm: update vRTCT module to support new vLAPIC solution
Emulation of guest lapic ID has been enhanced to
 indicate the topology of vCPU hierarchy.

 This patch refine logic to build virtual RCTC_v1 table
 of guest to adapt above lapic ID changes.

Tracked-On: #6020
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-06-01 10:41:51 +08:00
Jie Deng c08ceb25c5 dm: NULL check of vq->used in virtio_net_ping_rxq
Add a check on this place to avoid NULL access issue.

Tracked-On: #6100
Signed-off-by: Jie Deng <jie.deng@intel.com>
2021-06-01 08:22:45 +08:00
Rong Liu 8f6c17f1f1 dm: check if PTM root is enabled
hv is responsible to ensure PTM is always enabled on hw root port if
that root port is PTM root-capable.  If PTM root is not enabled already in physical
root port before guest launch, guest OS can only enable it in root port's virtual
config space and PTM may not function as desired so we would rather not
to allow user to enable PTM on pass-thru device in this case.
Also revisit a few comments to add assumption that acrn only support a
simple PTM hierarch emulation i.e., EP (ptm requestor) is directly connected
to root port (ptm root), or ptm requestor is rcie).

V4:
 - Change behavior from V3: When users tries to enable PTM while PTM root is not enabled on
physical root port, allow user to launch VM and pass thru the device
with no PTM support.
V3:
 - When users tries to enable PTM while PTM root is not enabled on
physical root port, allow user to launch VM and enable PTM in virtual
root port.  This is not going to enable PTM on physical root port.

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Jason Chen <jason.cj.chen@intel.com>
2021-05-27 09:00:50 +08:00
Tao Yuhong c8ae79b332 DM: change 32-bit mmio limit to 3.5G
the VM 32-bit mmio window is 2G~3.5G

Tracked-On: #6011
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-05-26 13:52:46 +08:00
dongshen 818c821d04 dm: acpi: retrieve physical APIC IDs and use them to fill in the ACPI MADT table
Two utility functions are copied and adapted from hyerpervisor:
ffs64
bitmap_clear_nolock

Two public functions are provided for future use (such as for RTCTv2)
pcpuid_from_vcpuid
lapicid_from_pcpuid

Tracked-On: #6020
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2021-05-26 11:23:06 +08:00
dongshen 6680208ed9 dm: vmmapi: augment the vm_get_config() vmmapi to include a struct platform_info* parameter
This allows users to retrieve and use the requested platform_info information from hypervisor

Tracked-On: #6020
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2021-05-26 11:23:06 +08:00
Li Fei1 5939c1afba dm: rb: only free rb_entry when we remove this entry from the rb tree
Only free rb_entry when we remove this entry from the rb tree, otherwise, a
page fault would trigger when next rb itreation would access the freed rb_entry.

Tracked-On: #6056
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2021-05-24 13:24:28 +08:00
Peter Fang c66bbe9e67 OVMF release v2.5
- Change 64-bit MMIO BAR window to 256G-512G

The release is the same as 736a03222f.
This is just to update the changelog.

Tracked-On: #5913
Signed-off-by: Peter Fang <peter.fang@intel.com>
2021-05-21 10:23:23 +08:00
Peter Fang 66b92f3f4e dm: add allow_trigger_s5 mode to pm_notify_channel uart
A user can use "--pm_notify_channel uart,allow_trigger_s5" to indicate
the User VM is allowed to trigger system S5.

"--pm_notify_channel uart" means a vuart channel will be created in the
User VM to allow communication with the VM's life_mngr. The Service VM
can then initiate S5 in the guest via its dm's monitor interface. The
additional option, "allow_trigger_s5", will create a socket connection
with the Service VM's life_mngr, allowing this VM to initiate system S5.

v1 -> v2:
- rename pm_notify_channel type to PWR_EVENT_NOTIFY_UART_TRIG_PLAT_S5

Tracked-On: #6034
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-05-21 10:16:30 +08:00
Helmut Buchsbaum 596f27bad3 Makefile: Make builds reproducible
Make builds reproducible by honoring SOURCE_DATE_EPOCH and USER
environment variables in the respective Makefiles. Just follow the
recommendations at https://reproducible-builds.org/

Build tools (e.g. Debian packaging, Yocto) use this to ensure reproducibility
of packages.

Tracked-On: #6035
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2021-05-20 10:02:33 +08:00
Rong Liu df64877c50 dm: PTM: Check PTM root has more than one child
Add one more sanity check: If the root port has more than
	one child, we won't enable PTM on the guest.
	This is not necessarily an error.  We flag it as
	error just because we don't have this type of hw
	configuration at development time thus this configuration
	is not tested.

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Rong Liu 721c866d63 dm: PTM: Enable ptm on passthru device
If user sets enable_ptm option on passthru device, passthru device
	calls ptm_probe() to check and enable ptm on passthru device.  If error
	is found during sanity check, ptm will not be enabled in the guest
	and an error will be reported to user.  However, this doesn't
	prevent user from launching guest and passing through the device to the guest.
	If no error is found, PTM is enabled in the guest and the
	passthru device will connect to virtual root port (which acts as PTM
	root) instead of virtual host bridge.

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Rong Liu 7e93f31e2c dm: PTM: Add virtual root port to vm
If PTM can be enabled on passthru device, a virtual root port
	is added to vm to act as ptm root.  And the passthru device is
	connected to the virtual root port instead of the virtual host bridge.

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Rong Liu d5d792aa96 dm: PTM: Check if hw supports ptm
This patch probes whether hw supports ptm.  It is used to check whether ptm
	can be enabled on the passthru pci device.  It checks whether passthru
	device support PTM requestor capability, then check whether its upstream
	root port support PTM root role.  Errors are reported to user if sanity
	check fails.

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Rong Liu a7b0d9848f dm: PTM: Get # of children of a pci bridge or pci bus
Add functionality to build and cache pci hierarchy, which are mainly
    used to retrieve # of children of pci bridge or pci bus.

    get_device_count_on_bus(): get # of child devices on a pci bus
    get_device_count_on_bridge(): recursively get # of child devices on a pci bridge
    scan_pci(): build and cache pci hierarchy
    pci_find_root_port(): find root port of a pci device
    clean_pci_cache(): free pci cache
    scan_pci_test(): test of scan pci hierarchy (disabled)

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Rong Liu d3185f8a0c dm: PTM: Add a few pci utility functions
Add a few pci utility functions to help easy access of pci
    functionalities.
    1. pci_find_capability(): find position of specified pci capability register
    2. pci_find_ext_cap(): find extend capability register position from cap_id
    3. pci_pcie_type(): find pci-e device type
    4. is_root_port(): check whether pdev is a pci root port
    5. is_bridge(): check whether pdev is a bridge

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Yin Fengwei 1e033f9d89 build: fix dm and acrn_crashlog build error with gcc-11
Unify two functions definitions/declarifications:
  Update the parameters from char array to char pointer.
to fix the build issue:
  probeutils.c:61:29: error: argument 1 of type 'char *' declared
  as a pointer [-Werror=array-parameter=]

Initialize local variable "c" to fix build issue:
  core/mevent.c:122:21: error: 'c' may be used uninitialized
  [-Werror=maybe-uninitialized]

Tracked-On: #5993
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2021-05-19 11:38:18 +08:00