Commit Graph

4544 Commits

Author SHA1 Message Date
Junming Liu f27d47542a dm:gvt:adjust pci bar region with reserved bar regions
ACRN-DM has reserved gvt bar regions.

This patch ensures other pci devices' bar regions
won't overlap with reserved bar regions.

v6 -> v7:
	* rename some struct and func

v5 -> v6:
	* remove outdated comment
	* add comments for code reading
	* code cleaning about gvt bar0 and bar2 size

v4 -> v5:
	* rename adjust_bar_region and adjust_bar_region_by_gvt_bars
	* change adjust_bar_region_by_gvt_bars interface for code cleaning

v3 -> v4:
	* add static struct gvt_region  instead of definition or pointer array.

v2 -> v3:
	* repalce pci_emul_alloc_bar with gvt_reserve_resource when allocate gvt bars
	* use register_bar to detect if gvt bars confilts with pci devices

v1 -> v2:
	* don't limit the gvt bar type is MEM32 when deal with pci bar
	* add is_two_region_overlap func to detect if two regions overlap
	* add region array to store gvt bar0 and bar2 regions

Tracked-On: projectacrn#4005

Signed-off-by: Junming Liu <junming.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Liu XinYun <xinyun.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-12-05 11:20:11 +08:00
Junming Liu 1ac0b57c6a dm:gvt:reserve gvt bar regions in ACRN-DM
The current design has the following problem:
gvt uses some pci bar regions,
but ACRN-DM isn't aware of these regions.
So ACRN-DM may allocate these regions for other pci devices,
which will result in other pci devices bar regions
overlap with gvt bar regions.

The new design is the following:
(1) ACRN-DM reads gvt bar regions
which are provided by physical gpu;
(2) ACRN-DM reserves gvt bar regions

v6 -> v7:
	* use array to store reserved bar regions
	* rename some struct and func

v5 -> v6:
	* rename enable_gvt to gvt_enabled
	* add a interface to reserve bar regions
	* reserve gvt bar regions

Tracked-On: projectacrn#4005

Signed-off-by: Junming Liu <junming.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Liu XinYun <xinyun.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-12-05 11:20:11 +08:00
Shuo A Liu 72644ac2b2 hv: do not sleep a non-RUNNING vcpu
It's meaningless to sleep a non-running vcpu. Add a state check before
sleep the thread object of the vcpu.

Tracked-On: #4178
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-05 11:19:35 +08:00
Shuo A Liu d624eb5e6c hv: io: do schedule in IO completion polling loop
Now, we support schedule inplace. And with cpu sharing, there might be
multi vcpu running on same pcpu. Reschedule request will happen when
switch the running vcpu. If the current vcpu is polling on the IO
completion, it need to be scheduled back to the polling point.

In the polling path, construct a loop for polling, and do schedule in the
loop if needed.

Tracked-On: #4178
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-05 11:19:35 +08:00
Conghui Chen d48da2af3a hv: bugfix for debug commands with smp_call
With cpu-sharing enabled, there are more than 1 vcpu on 1 pcpu, so the
smp_call handler should switch the vmcs to the target vcpu's vmcs. Then
get the info.

dump_vcpu_reg and dump_guest_mem should run on certain vmcs, otherwise,
there will be #GP error.

Renaming:
vcpu_dumpreg -> dump_vcpu_reg
switch_vmcs -> load_vmcs

Tracked-On: #4178
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-05 11:19:35 +08:00
Shuo A Liu 47139bd78c hv: print current sched_object in acrn logmsg
Add a header field in acrnlog message to indicate the current
running thread.

Tracked-On: #4178
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-05 11:19:35 +08:00
Shuang Zheng 5eb8040284 acrn-config: update UI to support virtio devices
Add multi device editing UI for Virtio-net and virtio-blk devices.

Tracked-On: #4185
Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
2019-12-04 16:52:40 +08:00
Wei Liu 5309e41528 acrn-config: modify the description of usb xhci
modify the description of usb xhci about the input format.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-04 16:52:40 +08:00
Wei Liu 7838b53763 acrn-config: add virtio-net mediator support for launch config
Add virtio-net mediator support to parse and get 'virtio-network' item value
from launch config files, these values are editable by user.

Tracked-On: #4185
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-04 16:52:40 +08:00
Wei Liu 25b2a26e34 acrn-config: add 'virtio-network' info in launch xmls
Some vm need mediator of 'virtio-net', so add 'virtio-network'
item into the launch config files that user could edit them from webUI.

Tracked-On: #4185
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-04 16:52:40 +08:00
Wei Liu 8464419af3 acrn-config: add virtio-block support for launch config
Add virtio-block support to parse and get 'block' item value
from launch config files, these values are editable by user.

Tracked-On: #4172
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-04 16:52:40 +08:00
Wei Liu 40140281ae acrn-config: add rootfs_dev/rootfs_img with virtio-blk item
remov rootfs_dev and rootfs_img item and replace them with vritio-blk
item.

The format for virtio-blk:
[blk partition:][img path] e.g.: /dev/sda3:./a/b.img

For vbootloader of ovmf: [img path] e.g.:./a/b.img

Tracked-On: #4172
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-04 16:52:40 +08:00
Kaige Fu aedd2c70e7 acrntrace: parse leaf and subleaf of cpuid
We have changed the cpuid trace-entry in HV to trace
the leaf and subleaf of cpuid. This patch modifies the
format accordingly.

Tracked-On: #4175
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-12-03 16:34:14 +08:00
Kaige Fu aae974b473 HV: trace leaf and subleaf of cpuid
We care more about leaf and subleaf of cpuid than vcpu_id.
So, this patch changes the cpuid trace-entry to trace the leaf
and subleaf of this cpuid vmexit.

Tracked-On: #4175
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-12-03 16:34:14 +08:00
Sainath Grandhi 77039f2911 acrn-config: Extend ve820 generation script for sizes gt 512 MB
Current ve820 generation script assumes the size of pre-launched
VM memory is less than or equal to 512 MB (Must be the assumption
of logical partition scenario as such).
This patch extends the script to handle pre-launched VM memory
sizes greater than 512 MB.

Tracked-On: #4182
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-03 14:42:55 +08:00
Yonghua Huang 450d2cf2e9 hv: trap RDPMC instruction execution from any guest
PMU is hidden from any guest, UD is expected when guest
try to execute 'rdpmc' instruction.

this patch sets 'RDPMC exiting' in Processorbased
VM-execution control.

Tracked-On: #3453
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-03 14:14:27 +08:00
Binbin Wu 3d412266bc hv: ept: build 4KB page mapping in EPT for RTVM for MCE on PSC
Deterministic is important for RTVM. The mitigation for MCE on
Page Size Change converts a large page to 4KB pages runtimely during
the vmexit triggered by the instruction fetch in the large page.
These vmexits increase nondeterminacy, which should be avoided for RTVM.
This patch builds 4KB page mapping in EPT for RTVM to avoid these vmexits.

Tracked-On: #4101
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-03 09:17:04 +08:00
Binbin Wu 0570993b40 hv: config: add an option to disable mce on psc workaround
Add a option MCE_ON_PSC_WORKAROUND_DISABLED to disable the software
workaround for the issue Machine Check Error on Page Size Change.

Tracked-On: #4101
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-03 09:17:04 +08:00
Binbin Wu 192859ee02 hv: ept: apply MCE on page size change mitigation conditionally
Only apply the software workaround on the models that might be
affected by MCE on page size change. For these models that are
known immune to the issue, the mitigation is turned off.

Atom processors are not afftected by the issue.
Also check the CPUID & MSR to check whether the model is immune to the issue:
CPU is not vulnerable when both CPUID.(EAX=07H,ECX=0H).EDX[29] and
IA32_ARCH_CAPABILITIES[IF_PSCHANGE_MC_NO] are 1.

Other cases not listed above, CPU may be vulnerable.

This patch also changes MACROs for MSR IA32_ARCH_CAPABILITIES bits to UL instead of U
since the MSR is 64bit.

Tracked-On: #4101
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-03 09:17:04 +08:00
Shuo A Liu 3cb32bb6e3 hv: make init_vmcs as a event of VCPU
After changing init_vmcs to smp call approach and do it before
launch_vcpu, it could work with noop scheduler. On real sharing
scheudler, it has problem.

   pcpu0                  pcpu1            pcpu1
 vmBvcpu0                vmAvcpu1         vmBvcpu1
                         vmentry
init_vmcs(vmBvcpu1) vmexit->do_init_vmcs
                    corrupt current vmcs
                        vmentry fail
launch_vcpu(vmBvcpu1)

This patch mark a event flag when request vmcs init for specific vcpu. When
it is running and checking pending events, will do init_vmcs firstly.

Tracked-On: #4178
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-02 16:20:43 +08:00
Victor Sun 15da33d8af HV: parse default pci mmcfg base
The default PCI mmcfg base is stored in ACPI MCFG table, when
CONFIG_ACPI_PARSE_ENABLED is set, acpi_fixup() function will
parse and fix up the platform mmcfg base in ACRN boot stage;
when it is not set, platform mmcfg base will be initialized to
DEFAULT_PCI_MMCFG_BASE which generated by acrn-config tool;

Please note we will not support platform which has multiple PCI
segment groups.

Tracked-On: #4157

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-02 16:20:24 +08:00
Wei Liu 80a7281f1e acrn-config: add MMCFG_BASE_INFO item in board config
Parse MMCFG base address value and store it to board config xml
as DEFAULT_PCI_MMCFG_BASE macro.

Tracked-On: #4173
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-02 16:19:55 +08:00
Wei Liu 0e273e996c acrn-config: get default pci mmcfg base address
parse default pci mmcfg base address from target board.

Tracked-On: #4173
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-12-02 16:19:55 +08:00
Yan, Like 0d998d6ac6 hv: sync physical and virtual TSC_DEADLINE when msr interception enabled/disabled
Starting with TSC_DEADLINE msr interception disabled, the virtual TSC_DEADLINE msr is always 0.
When the interception is enabled, need to sync the physical TSC_DEADLINE value to virtual TSC_DEADLINE.

When the interception is disabled, there are 2 cases:
 - if the timer hasn't expired, sync virtual TSC_DEADLINE to physical TSC_DEADLINE, to make the guest read the same tsc_deadline
   as it writes. This may change when the timer actually trigger.
 - if the timer has expired, write 0 to the virtual TSC_DEADLINE.

Tracked-On: #4162
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-02 16:10:50 +08:00
Yan, Like 97916364fc hv: fix virtual TSC_DEADLINE msr read/write issues
When write to virtual TSC_DEADLINE, if virtual TSC_ADJUST is not zero:
 - when guest intends to disarm the tsc_deadline timer, should not arm the timer falsely;
 - when guest intends to arm the tsc_deadline timer, should not disarm the timer falsely.

When read from virtual TSC_DEADLINE, if virtual TSC_ADJUST is not zero:
 - if physical TSC_DEADLINE is not zero, return the virtual TSC_DEADLINE value;
 - if physical TSC_DEADLINE is zero which means it's not armed (automatically disarmed after
   timer triggered), return 0 and reset the virtual TSC_DEADLINE.

Tracked-On: #4162
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-02 16:10:50 +08:00
Conghui Chen e61412981d hv: support xsave in context switch
xsave area:
    legacy region: 512 bytes
    xsave header: 64 bytes
    extended region: < 3k bytes

So, pre-allocate 4k area for xsave. Use certain instruction to save or
restore the area according to hardware xsave feature set.

Tracked-On: #4166
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-02 09:31:12 +08:00
Conghui Chen 8ba203a165 hv: change xsave init function name
change pcpu_xsave_init to init_pcpu_xsave.

Tracked-On: #4166
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-12-02 09:31:12 +08:00
Wei Liu 12a3ec8aa1 acrn-config: remove redundant get_leaf_tag_map in launch config lib
The function of get_leaf_tag_map(info_file, prime_item, item='') in
launch_config_lib.py is redundant and it will be called incorrectly
when generating the launch script. This patch remove the function.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
2019-11-29 16:28:27 +08:00
Wei Liu 2c2ccfc52c acrn-config: support OVMF vbootloader only
In current implementation, we only support OVMF as vbootloader, so
set vbootloader attributes to readonly in related XMLs to avoid issues.

Tracked-On: #3854

Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu 38a647c8a5 acrn-config: correct epc_section base/size value
Current epc_section base/size vaule missed vm id so the configure item is not
working, the patch will fix this issue.

Tracked-On: #4165
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu 91330eaa72 acrn-config: add usb xhci mediator support for
launch config

Add USB xHCI mediator support to parse and get 'usb_xhci' item value
from launch config files, these values are editable by user.

Tracked-On: #4164
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu 420b65a61e acrn-config: add 'usb_xhci' info to launch xmls
Some vm need USB xHCI mediator support, this patch add 'usb_xhci' item
to the launch config files that user can edit it from webUI.

Tracked-On: #4164
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu bc9b6d1b0c acrn-config: add virtio-input support for launch
config

Add support to parse and get 'virtio-input' item value from launch config
files, these values are editable by user.

Tracked-On: #4163
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu 9fc32043aa acrn-config: add 'virtio-input' info in launch xmls
Some vm need mediator of 'virtio-input', so add 'virtio-input' item
into the launch config files that user could edit them from webUI.

Tracked-On: #4163
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu 71c51a8f6f acrn-config: refinement for library config
Some API calls have the same function in library config,
the patch refines the API calls.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 13:36:27 +08:00
Wei Liu 1e2333647e acrn-config: skip the DRHDn_IGNORE when no device scope
Skip to generate DRHDn_IGNORE to board.c, when there is no device scope
type on target platform DRHD definition.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu 40929efe4b acrn-config: walk secondary PCI Bus for target board
There may be more than one PCI segment in target board, and DRHD info
should be parsed correctly base on secondary PCI bus. currently
board_parser.py tool did not handle such case.
Add this patch for walking secondary PCI Bus.

Tracked-On: #4143
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu 5e9234203a acrn-config: refinement for DmarDevScope struct
Refine the DmarDevScope struct and some class names.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu f6e6ec4ca2 acrn-config: modify SDC config xml to support kata vm config in webUI
Support to config kata vm in webUI, this need to modify 'configurable' attribute
to '1' in vm item.

Tracked-On: 4145
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Shuang Zheng bb2218effc acrn-config: add UI to add or remove Kata VM for sdc scenario
add UI to add or remove Kata VM for sdc scenario, the added Kata VM
is based on the generic config xml.

Tracked-On: 4145
Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu 31d023e8f9 acrn-config: launch refinement on vcpu affinity and uos image
1. The vcpus of UOS are configured in vm configuration, they should be offlined from
sos before vm start.
2. retry offline cpu for all UOS type.
3. uos image name will be based on vm name instead of input parameter.
4. correct the unexpected token ';;' in launch config.

Tracked-On: #4145
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu d581473c82 acrn-config: refine vcpu affinity/number for SDC scenario
For SDC scenario, support kata vm would be triggered from webUI, and
will store the kata vm information to the scenario config file.
Then, vcpu affinity/number should be refined for vm1 and kata vm.

Note: with this patch, user should add/remove the kata vm in SDC
scenario webUI and its number should match MAX_KATA_VM_NUM in
hypervisor/arch/x86/Kconfig.

Tracked-On: #4145
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu d44440f734 acrn-config: print warning if MMIO BAR size above 4G
Currently MMIO BAR size not support size above 4G,
print warning to user to set the MMIO size in 4G region from BIOS.

Target-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Wei Liu dc2d6b6656 acrn-config: modify the git commit message for gen_patch
Minor changes on git commit message of config patch:
For board config patch, specify with "config patch for board xxx";
For scenario config patch, specify with "config patch for scenario yyy".

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
2019-11-29 09:05:33 +08:00
Li Fei1 2c4ebdc695 hv: vmsi: name vmsi with verb-object style
Name vmsi and vmsix function with verb-object style:
For external APIs, using MODULE_NAME_verb-object style;
For internal APIs, using verb-object style.

Tracked-On: #3475
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2019-11-29 08:53:07 +08:00
Li Fei1 6ee076f7df hv: assign: rename ptirq_msix_remap to ptirq_prepare_msix_remap
ptirq_msix_remap doesn't do the real remap, that's the vmsi_remap and vmsix_remap_entry
does. ptirq_msix_remap only did the preparation.

Tracked-On: #3475
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2019-11-29 08:53:07 +08:00
Geoffroy Van Cutsem 51a43dab79 hv: add Kconfig parameter to define the Service VM EFI bootloader
Add a Kconfig parameter called UEFI_OS_LOADER_NAME to hold the Service VM EFI
bootloader to be run by the ACRN hypervisor. A new string manipulation function
to convert from (char *) to (CHAR16 *) has been added to facilitate the
implementation.

The default value is set to systemd-boot (bootloaderx64.efi)

Tracked-On: #2793
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-11-27 10:38:49 +08:00
Junhao Gao 058b03c3a7 dm: fix memory free issue for xhci
remove uninitialized variable "dir", then make sure
"xfer->data","xfer->data[i].hcb","xfer->reqs" free correctly.

Tracked-On: #4154
Signed-off-by: Junhao Gao <junhao.gao@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-11-27 10:22:27 +08:00
Sainath Grandhi 422330d4ab HV: reimplement PCI device discovery
Major changes:

1. Correct handling of device multi-function capability

We only check function zero for this feature. If it has it, we continue
looking at all remaining functions, ignoring those with invalid vendors.
The PCI spec says we are not to probe beyond function zero if it does
not exist or indicates it is not a multi-function device.

2a. Walk *ALL* buses in the PCI space, however,
Before walking the PCI hierarchy, post-processed ACPI DMAR info is parsed
and a map is created between all device-scopes across all DRHDs and the
corresponding IOMMU index.

This map is used at the time of walking the PCI hierarchy. If a BDF that
ACRN is currently working on, is found in the above-mentioned map, the
BDF device is mapped to the corresponding DRHD in the map.
If the BDF were a bridge type, realized with "Header Type" in config space,
the BDF device along with all its downstream devices are mapped to the
corresponding DRHD in the map.

To avoid walking previously visited buses, we maintain a bitmap that
stores which bus is walked when we handle Bridge type devices.

Once ACPI information is included into ACRN about the PCI-Express Root
Complexes / PCI Host Bridges, we can avoid the final loop which probes
all remainder buses, and instead jump to the next Host Bridge bus.

From prior patches, init_pdev returns the pdev structure it created to
the caller. This allows us to complete initialization by updating its
drhd_idx to the correct DRHD.

Tracked-On: #4134
Signed-off-by: Alexander Merritt <alex.merritt@intel.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-11-27 09:49:32 +08:00
Alexander Merritt 94a456ae24 HV: refactor device_to_dmaru
On server platforms, DMAR DRHD device scope entries may contain PCI
bridges.

Bridges in the DRHD device scope indicate this IOMMU translates for all
devices on the hierarchy below that bridge.

ACRN is unaware of bridge types in the device scope, and adds these
directly to its internal representation of a DRHD. When looking up a BDF
within these DRHD entries, device_to_dmaru assumes all entries are
Endpoints, comparing BDF to BDF. Thus device to DMAR unit fails, because
it treats a bridge as an Endpoint type.

This change leverages prior patches by converting a BDF to the
associated device DRHD index, and uses that index to obtain the correct
DRHD state.

Handling a bridge in other ways may require maintaining a bus list for
each, or replacing each bridge in the dev scope with a set of all device
BDFs underneath it. Server platforms can have hundreds of PCI devices,
thus making the device scope artificially large is unwieldy.

Tracked-On: #4134
Signed-off-by: Alexander Merritt <alex.merritt@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-11-27 09:49:32 +08:00