Commit Graph

6301 Commits

Author SHA1 Message Date
Jiang, Yanting e9d1fa1f98 config-tools: fix guest_flag issue in config xml for adl
commit 873ed75 ("misc: sanity check VM config for nested virtualization")
requires that the guest_flag tag can't be empty, or it will fail to build.

This patch changes adl instances of "<guest_flag></guest_flag>" to
"<guest_flag>0</guest_flag>".

Tracked-On: #5923
Signed-off-by: Jiang, Yanting <yanting.jiang@intel.com>
2021-05-26 08:55:34 +08:00
Yang,Yu-chu 0c55743f50 config-tools: add <enable_ptm> and <PTM>
Add <enable_ptm> which configures ptm feature dm argument.
Add <PTM>n</PTM> to post-launched vms.

Tracked-On: #6054
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-05-25 11:32:11 +08:00
Yang,Yu-chu 346490a7dc config-tools: enable PTM through config-tools
Configure PTM in post-launched VM using <PTM> element. If the //vm/PTM
sets to 'y', pci_dev.c.xsl appends the virtual root port to
corresponding struct acrn_vm_pci_dev_config of that VM. Currently it
supports only post-launched VMs.

Configure enable_ptm for dm argument. If a uos/enable_ptm with uos id
= 'vm_id 'sets to 'y' and the vm/PTM with the same vm_id sets to 'y',
append an "enable_ptm" flag to the end of passthrough ethernet devices.
Currently there is only ethernet card can support the "enable_ptm"flag.

For the schema validation, the <PTM> can only be ['y', 'n'].

For the launched script validation, the <enable_ptm> can only be ['y',
'n']. If the <enable_ptm> sets to 'y' but the corresponding <PTM> sets
to 'n', the launch script will fail to generate.

Tracked-On: #6054
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-05-25 11:32:11 +08:00
Geoffroy Van Cutsem 68e4c66175 Update doc/tutorials/using_hybrid_mode_on_nuc.rst
Co-authored-by: David Kinder <david.b.kinder@intel.com>
2021-05-24 14:06:50 -04:00
Geoffroy Van Cutsem a9c4fb2039 Update doc/tutorials/using_hybrid_mode_on_nuc.rst
Co-authored-by: David Kinder <david.b.kinder@intel.com>
2021-05-24 14:06:50 -04:00
Geoffroy Van Cutsem d7c29968f0 doc: add more details to GSG for the hybrid scenario
Add a number of steps and details that were not called
out in the "Getting Started Guide for ACRN Hybrid Mode". Those
are not obvious to the first-time or novice user so the user
guide was hard to follow and confusing. At a high-level:
* How to build Zephyr
* How to install ACRN
* How to install the ACRN kernel

The hybrid scenario overview diagram has been updated too.

Tracked-On: #5992
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2021-05-24 14:06:50 -04:00
Yang,Yu-chu 1de47b0433 config-tools: build acrn with xslt generated pci_dev.c and board_info.h
Build acrn using xslt transformed pci_dev.c and board_info.h.

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 21:53:22 +08:00
Yang,Yu-chu 1b7a2c98f5 config-tools: add board_info.h.xsl
Add an xslt file "board_info.h.xsl". This file is used to
generate board_info.h which is used by hypervisor.

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 21:53:22 +08:00
Yang,Yu-chu a1a399c360 config-tools: add pci_dev.c.xsl
Add an xslt file "pci_dev.c.xsl". This file is used to
generate pci_dev.c which is used by hypervisor.

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 21:53:22 +08:00
Yang,Yu-chu ad4bbc3d32 config-tools: add acrn specific functions to lib.xsl
acrn:get-vbdf: get the virtual bdf from allocation.xml based on vmid and device name
acrn:get-pbdf: get physical bdf from <pci_dev>
acrn:ptdev-name-suffix: fix the name to look up allocation.xml
acrn:get-hidden-device-num: get the number of hidden devices based on
board name
acrn:is-vmsix-supported-device: check if a device is a vmsix supported
device based on the vendor and identifier

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-05-24 21:53:22 +08:00
Yang,Yu-chu 9736ab8295 config-tools: add bdf static allocator
Assign bdf to pci emulated and passthrough devices.

For pre-launched VM, assigns unique bdf to passthrough devices, inter-vm
shared memory, pci vuart(console and communication vuarts).

For SOS vm, assigns unique bdf to inter-vm shared memory and pci
vuart(console and communication vuarts).

The bdf follows the rules below:
- the bdf 00:00.0 is reserved for pci hostbridge
- the assigned bdf range: bus is 0x00, dev is in range [0x1, 0x20)
and the fuc is 0x00
- the bdf must be unique, which means any vm's emulated devices cannot
share the same bdf with existing devices
- some devices's bdf is hardcoded, modify its bdf would leads the
device cannot be dicoverd by os. A HARDCODED_BDF_LIST in bdf.py documents
them
- the passthrough devices' bdf can be reused in SOS vm

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 21:53:22 +08:00
Yang,Yu-chu 152d0bce5c config-tools: add methods to allocate mmio windows for emulated devices
Add methods allocates the mmio bar base to console vuart,
communication vuarts, inter-vm shared memory and passthrough pci
devices.

For SOS:
 - get low mem by parsing board xml.
 - get high mem by parsing board xml, if the high mem is not enabled,
 the high mem start address would be ~0UL and the end address is 0UL
 - get the occupied mmio windows by parsing board.xml
 - for each console vuart, communication vuart and inter-vm shared memory
 devices, assign unused mmio windows to them
 - all the assigned mmio windows must be unique and should not overlay
 with any devices' mmio window
 - the passthrough devices mmio windows can be reused in SOS vm
 - each allocated mmio start address must be 4k alignment if the length
 of bar is smaller than 4k
 - each allocated mmio start address must be aligned with the bar length
 if its length is greater than 4k
 - the 32bits bar will fall in low mem range only
 - 64bits bar will look for free mmio in low mem rage first, if the high
 mem is enabled, the 64bits bar will look for free mmio in high mem
 range if there is not enough space in low mem range
 - allocator raises an error if there is not enough mmio space

For pre-launched VM:
 - the high mem range is [256G, 512G)
 - the low mem range is [2G, 3.5G)
 - there is no used mmio window initially
 - for each console vuart, communication vuart, inter-vm shared memory
 devices and passthrough devices, assign unused mmio windows to them
 - all the assigned mmio windows must be unique and should not overlay
 with any devices' mmio window
 - the 32bits bar will fall in low mem range only
 - 64bits bar will look for free mmio in low mem rage first and then
 look for free mmio in high mem range if there is not enough space in
 low mem range
 - each allocated mmio start address must be 4k alignment if the length
 of bar is smaller than 4k
 - each allocated mmio start address must be aligned with the bar length
 if its lenght is greater than 4k
 - allocator raises an error if there is not enough mmio space

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 21:53:22 +08:00
Yang,Yu-chu c13acf3045 config-tools: add get_shmem_regions and vm type checking to lib.py
Add a common method "get_shmem_regions":
This method get <IVSHMEM_REGION> and extracts the region size, region
position in xml and and vm ids which share this regions. Returns a
dictionary:
{'vm_id':{'region_name':{'id': region position,'size': region size,}}}

Add vm type checking methods:
is_pre_launched_vm, is_post_launched_vm and is_sos_vm.

Tracked-On: #6024
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 21:53:22 +08:00
Kunhui Li 7943c944b8 Config_tools: Update board xml for acrn 2.5
Add nuc11tnbi5.xml;
Update adl-rvp.xml, cfl-k700-i7.xml, nuc7i7dnb.xml, whl-ipc-i5.xml and whl-ipc-i7.xml.

Tracked-On: #5922
Signed-off-by: Kunhui Li <kunhuix.li@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-05-24 16:35:46 +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
Zide Chen 6d69058a9d hv: nested: support for VMREAD and VMWRITE emulation
This patch implements the VMREAD and VMWRITE instructions.

When L1 guest is running with an active VMCS12, the “VMCS shadowing”
VM-execution control is always set to 1 in VMCS01. Thus the possible
behavior of VMREAD or VMWRITE from L1 could be:

- It causes a VM exit to L0 if the bit corresponds to the target VMCS
  field in the VMREAD bitmap or VMWRITE bitmap is set to 1.
- It accesses the VMCS referenced by VMCS01 link pointer (VMCS02 in
  our case) if the above mentioned bit is set to 0.

This patch handles the VMREAD and VMWRITE VM exits in this way:

- on VMWRITE, it writes the desired VMCS value to the respective field
  in the cached VMCS12. For VMCS fields that need to be synced to VMCS02,
  sets the corresponding dirty flag.

- on VMREAD, it reads the desired VMCS value from the cached VMCS12.

Tracked-On: #5923
Signed-off-by: Alex Merritt <alex.merritt@intel.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen 2bd269c11c hv: nested: support for VMCLEAR emulation
This patch is to emulate VMCLEAR instruction.

L1 hypervisor issues VMCLEAR on a VMCS12 whose state could be any of
these: active and current, active but not current, not yet VMPTRLDed.

To emulate the VMCLEAR instruction, ACRN sets the VMCS12 launch state to
"clear", and if L0 already cached this VMCS12, need to sync it back to
guest memory:

- sync shadow fields from shadow VMCS VMCS to cache VMCS12
- copy cache VMCS12 to L1 guest memory

Tracked-On: #5923
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen 5379b14108 hv: nested: define VMCS shadow fields
Enable VMCS shadowing for most of the VMCS fields, so that execution of
the VMREAD or VMWRITE on these shadow VMCS fields from L1 hypervisor
won't cause VM exits, but read from or write to the shadow VMCS.

Tracked-On: #5923
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Alexander Merritt <alex.merritt@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen 863e58e539 hv: nested: define software layout for VMCS12 and helper functions
Software layout of VMCS12 data is a contract between L1 guest and L0
hypervisor to run a L2 guest.

ACRN hypervisor caches the VMCS12 which is passed down from L1 hypervisor
by the VMPTRLD instructin. At the time of VMCLEAR, ACRN syncs the cached
VMCS12 back to L1 guest memory.

Tracked-On: #5923
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen f5744174b5 hv: nested: support for VMPTRLD emulation
This patch emulates the VMPTRLD instruction. L0 hypervisor (ACRN) caches
the VMCS12 that is passed down from the VMPTRLD instruction, and merges it
with VMCS01 to create VMCS02 to run the nested VM.

- Currently ACRN can't cache multiple VMCS12 on one vCPU, so it needs to
  flushes active but not current VMCS12s to L1 guest.
- ACRN creates VMCS02 to run nested VM based on VMCS12:
  1) copy VMCS12 from guest memory to the per vCPU cache VMCS12
  2) initialize VMCS02 revision ID and host-state area
  3) load shadow fields from cache VMCS12 to VMCS02
  4) enable VMCS shadowing before L1 Vm entry

Tracked-On: #5923
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen 0a1ac2f4a0 hv: nested: support for VMXOFF emulation
This patch implements the VMXOFF instruction. By issuing VMXOFF,
L1 guest Leaves VMX Operation.

- cleanup VCPU nested virtualization context states in VMXOFF handler.
- implement check_vmx_permission() to check permission for VMX operation
  for VMXOFF and other VMX instructions.

Tracked-On: #5923
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen 3fdad3c6d1 hv: nested: check prerequisites to enter VMX operation
According to VMXON Instruction Reference, do the following checks in the
virtual hardware environment: vCPU CPL, guest CR0, CR4, revision ID
in VMXON region, etc.

Currently ACRN doesn't support 32-bit L1 hypervisor, and injects an #UD
exception if L1 hypervisor is not running in 64-bit mode.

Tracked-On: #5923
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-05-24 10:34:01 +08:00
Zide Chen fc8f07e740 hv: nested: support for VMXON emulation
This patch emulates VMXON instruction. Basically checks some
prerequisites to enable VMX operation on L1 guest (next patch), and
prepares some virtual hardware environment in L0.

Tracked-On: #5923
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@Intel.com>
2021-05-24 10:34:01 +08:00
Tao Yuhong b93d6b2ef0 HV: Fix mistake use stac() & clac()
The commit 2ab70f43e5
HV: cache: Fix page fault by flushing cache for VM trusty RAM in HV

It is wrong in using stac()/clac()

Tracked-On: #6020
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-05-24 10:32:54 +08:00
Li Fei1 6077152c4b hv: vlapic: extend vlapic_x2apic_pt_icr_access to support more destination mode
Now guest would use `Destination Shorthand` to broadcast IPIs if there're more
than one destination. However, it is not supported when the guest is in LAPIC
passthru situation, and all active VCPUs are working in X2APIC mode. As a result,
the guest would not work properly since this kind broadcast IPIs was ignored
by ACRN. What's worse, ACRN Hypervisor would inject GP to the guest in this case.

This patch extend vlapic_x2apic_pt_icr_access to support more destination modes
(both `Physical` and `Logical`) and destination shorthand (`No Shorthand`, `Self`,
`All Including Self` and `All Excluding Self`).

Tracked-On: #5923
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-05-24 10:27:32 +08:00
Li Fei1 a69e67b58b hv: vlapic: wrap a function to calculate destination vcpu mask by shorthand
1. Rename vlapic_calc_dest to vlapic_calc_dest_noshort
2. Remove vlapic_calc_dest_lapic_pt, use vlapic_calc_dest_noshort instead
3. Wrap vlapic_calc_dest to calculate destination vcpu mask according shorthand

Tracked-On: #5923
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-05-24 10:27:32 +08:00
Peter Fang b068656e71 doc: add documentation for allow_trigger_s5 in pm_notify_channel
Tracked-On: #6034
Signed-off-by: Peter Fang <peter.fang@intel.com>
2021-05-21 12:08:24 -04: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
Tao Yuhong 2ab70f43e5 HV: cache: Fix page fault by flushing cache for VM trusty RAM in HV
The accrss right of HV RAM can be changed to PAGE_USER (eg. trusty RAM
of post-launched VM). So before using clflush(or clflushopt) to flush
HV RAM cache, must allow explicit supervisor-mode data accesses to
user-mode pages. Otherwise, it may trigger page fault.

Tracked-On: #6020
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-05-21 09:20:46 +08:00
Kunhui Li a1f12d2931 Config_tools: Update ramdisk logic
Update the ramdisk config logic.

Tracked-On: #6038
Signed-off-by: Kunhui Li <kunhuix.li@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2021-05-21 09:20:10 +08:00
David B. Kinder b8ef1a87be doc: fix indenting issues in tutorial
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2021-05-20 17:18:44 -04:00
Benjamin Fitch 2c4249fb96 doc: copy editing in the hld topics
Signed-off-by: Benjamin Fitch <benjamin.fitch@intel.com>
2021-05-20 09:15:35 -07:00
Victor Sun 5df3455e8d HV: remove SOS kernel hugepage related bootargs
Hypervisor does not need to care about hugepage settings in SOS kernel, user
could enable these settings in the scenario config file or GRUB menu.

Tracked-On: #5815
Signed-off-by: Victor Sun <victor.sun@intel.com>
2021-05-20 13:31:56 +08:00
Victor Sun ef737c3089 HV: refine init_vm_bootargs_info()
changes:
	1. The VM load order type condition is not needed, since the function
	   is called only when create SOS VM or pre-launched VM;
	2. Fixed wrong parameter of fill_seed_arg() which introduced by commit
	   80262f0602.
	3. More comments on why multiboot string could override the pre-
	   configured VM bootargs and why append multiboot cmdline to SOS VM
	   bootargs;

Tracked-On: #5815
Signed-off-by: Victor Sun <victor.sun@intel.com>
2021-05-20 13:31:56 +08:00
Kunhui Li 27b3ebfad4 Config_tools: config hugepage in sos kenrel cmdline
If there is hugepage support from board xml, config tool will
add hugepagesz=1G hugepages=[size] into sos kernel cmdline,
the size is calculated by memory size in G minusing 3.
The reason for reducing 3 is that it is reserved for SOS VM use.

Tracked-On: #5815
Signed-off-by: Kunhui Li <kunhuix.li@intel.com>
Reviewed-By: Junjie Mao <junjie.mao@intel.com>
2021-05-20 13:31:56 +08:00
Helmut Buchsbaum e88955392f Makefile: lifemngr: split linux and windows build
* Split linux and windows build of lifemngr to be able to build
  them independently.
* Install life_mngr.service
* Avoid the following Makefile error output by explicitly checking
  Windows cross compiler availability:

make[4]: x86_64-w64-mingw32-gcc: Command not found
make[4]: [Makefile:47: all-win] Error 127 (ignored)

Tracked-On: #5660
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2021-05-20 10:02:33 +08:00
Helmut Buchsbaum b673bc36b1 Makefile: honor BUILD_VERSION and BUILD_TAG
Use BUILD_VERSION an BUILD_TAG variable also for hypervisor,
acrnprobe and crashlog. This eases build from an archive without
git available.

Tracked-On: #6035
Signed-off-by: Helmut Buchsbaum <helmut.buchsbaum@opensource.tttech-industrial.com>
2021-05-20 10:02:33 +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 3db4491e1c hv: PTM: Create virtual root port
Create virtual root port through add_vdev hypercall. add_vdev
identifies the virtual device to add by its vendor id and device id, then
call the corresponding function to create virtual device.

	-create_vrp(): Find the right virtual root port to create
by its secondary bus number, then initialize the virtual root port.
And finally initialize PTM related configurations.

	-destroy_vrp(): nothing to destroy

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Jason Chen <jason.cj.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +08:00
Rong Liu d57bf51c89 hv: PTM: Add virtual root port
Add virtual root port that supports the most basic pci-e bridge and root port operations.

	- init_vroot_port(): init vroot_port's basic registers.

	- deinit_vroot_port(): reset vroot_port

	- read_vroot_port_cfg(): read from vroot_port's virtual config space.

	- write_vroot_port_cfg(): write to vroot_port's virtual config space.

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Jason Chen <jason.cj.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-05-19 13:54:24 +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
Junjie Mao 54fc26875e config_tools: update board XMLs of ehl-crb-b and tgl-rvp
This patch applies the latest board inspector on ehl-crb-b and tgl-rvp to
generate additional information to the board XMLs.

Tracked-On: #5922
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-19 09:10:46 +08:00
Junjie Mao 99f15a27c2 board_inspector/acpiparser: enable parsing RTCT v2
This patch adds support to parse RTCT v2 using the refined board XML
schema. The major changes include:

 - Add the RTCT v2 parser in the acpiparser module. The version of an RTCT
   is detected automatically to choose the right parser.
 - Extract software SRAM capabilities of caches into the board XML.
 - Move the logic that determines the software SRAM base address for the
   pre-launched VM to the static allocator of GPAs.
 - Generate software SRAM related macros into misc_cfg.h when necessary.

Tracked-On: #6020
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-05-19 08:53:38 +08:00