Commit Graph

6298 Commits

Author SHA1 Message Date
Yifan Liu
69d0440c4c hv: reserve smbios table region in ve820
Reserve SMBIOS table region in ve820 to prevent kernel from using it.
it.

Tracked-On: #7735
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2022-06-10 10:10:22 +08:00
Minggui Cao
79359441ff hv: improve vmexit array size to avoid overflow
change vmexit data array size according to vmexit dispatch_table size.
also add a size check to avoid array overflow.

Tracked-On: #7043
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2022-01-19 13:35:00 +08:00
Xiangyang Wu
f4e0bf34dd HV: update destination shorthand during x2apic ICR emulation
Currently, in RTVM with multi vCPUs, lapic pass through is
configured, each vCPU works in x2apic mode. When one vCPU sends
IPI to all other vCPUs through writes ICR register with virtual
value 0x00000000000c00f8, this ICR writting will be intercepted,
the hypervisor passes destination shorthand field 11B (All Excluding
Self) in the virtual ICR value into physical ICR value during IPI
emulation, this IPI will be sent to each physical CPU core
in the platform according to 10.6.1 Interrupt Command Register (ICR),
Vol 3, SDM.
One vCPU in User VM with lapic pass through configuration can
send IPI with destination shorthand (10B or 11B) and any vector
(such as NMI or reboot vector) to other vCPUs, this IPI will sent
other VMs in the platform by hypervisor, this interference may
cause other VMs hang.

In this patch, set "Destination Shorthand" field of the
ICR value as 00B (No Shorthand) since the emulation is done
through sending IPI to each VCPU in dmask one by one.

Tracked-On: #6908

Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Reviewed-by: Chen, Jason CJ <jason.cj.chen@intel.com>
2021-12-01 15:52:02 +08:00
Yang,Yu-chu
1ca9061b6d config-tools: refine MAX_MSIX_TABLE_NUM
If the MAX_MSIX_TABLE_NUM is specified in scenario.xml. Return the
largest number from count of MSI, table_size of MSIX or
MAX_MSIX_TABLE_NUM of scenario.xml.

Tracked-On: #6235
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-11-15 13:40:34 +08:00
Fei Li
8333ba2c7b dm: pci: destory reseverd PIO BAR when deinit passthrough PCI device
Destory reseverd PIO BAR when deinit passthrough PCI device to free
reserved_bar_regions.

Tracked-On: #6508
Signed-off-by: Fei Li <fei1.li@intel.com>
2021-09-29 09:39:02 +08:00
Liu,Junming
7a0c814693 hv: refine the VMCS io bitmap handling when pass-thru PIO bar
In current design, when pass-thru dev,
for the PIO bar, need to ensure the guest PIO start address
equals to host PIO start address.
Then set the VMCS io bitmap to pass-thru the corresponding
port io to guest for performance.

But malicious guest may reprogram the PIO bar,
then hv will pass-thru the reprogramed PIO address to guest.
This isn't safe behavior.

Here only pass-thru the host physical device PIO to guest.
If guest regrogram the PIO bar, just update the virtual bar only.
Currently, we don't support PIO bar reprogramming,
if guest reprogram the PIO bar, guest should take responsibility itself

When init the pass-thru dev PIO bars, set the VMCS io bitmap.
setup_io_bitmap is called before init pass-thru dev to
initiailize the io bitmap, so don't need to
call deny_guest_pio_access when deinit pass-thru dev.

v1 -> v2:
	* set the VMCS io bitmap when init pass-thru devices
	to migrate redoing allow_guest_pio_access()/deny_guest_pio_access().

Tracked-On: #6508

Signed-off-by: Liu,Junming <junming.liu@intel.com>
2021-09-29 09:39:02 +08:00
Fei Li
d8af5f2cb4 dm: identical mapping of pass-thru dev PIO bar
For pass-thru dev PIO bar,keep identical mapping

Tracked-On: #6508

Signed-off-by: Fei Li <fei1.li@intel.com>
2021-09-29 09:39:02 +08:00
Weiyi-Feng
13af32d166 Update doc/getting-started/roscube/roscube-gsg.rst
Co-authored-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2021-09-24 15:24:45 -07:00
Weiyi Feng
c190272955 doc: update the ROScube-I GSG with ACRN v2.5
This patch updates the ROScube-I GSG so that developers could use ROScube-I
with ACRN v2.5.

Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
2021-09-24 15:24:45 -07:00
Minggui Cao
61074ce1ee hv: enable CAT for tgl-rvp
enable CAT for tgl-rvp on release-v2.5

Configure LLC CAT rt-core: 0xf00, others: 0x0ff

Tracked-On: #6547
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2021-09-09 09:53:26 +08:00
Junjie Mao
55e8443571 board_inspector/cli: export PATH to the legacy board parser
Customized environment variables are not inherited to child processes
created by the subprocess module. As a result the legacy board parser may
not be able to locate the prerequisite utilities if they can be found only
with the customized PATH.

This patch passes the PATH of cli.py to the legacy parser so that both
scripts use the same PATH to search for utilities.

This patch is added in v2 of the series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-09-04 18:55:48 +08:00
Zhou, Wu
b9f3e6c929 HV: Fix the problem of copy fail when booting pre-launched VMs
The length of the ACPI data entry in ve820 tab was 960K, while the
ACPI file is 1MB. It would cause ept unmapped fault when loading the
pre-launched VMs. This patch changes it to 1MB to fix the problem.

And the ACPI data length was missed when calculating
ENTRY_HPA1_LOW_PART2 length. Fixed here too.

The vACPI data and NVS entry size for pre-launched VM is currently
hard-coded. Add VIRT_ACPI_DATA_LEN and VIRT_ACPI_NVS_LEN to replace
them. And build connection with their starting address, too.

Tracked-On: #6507

Signed-off-by: Zhou, Wu <wu.zhou@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2021-09-04 18:54:45 +08:00
Jian Jun Chen
857890e788 hv: debug: add debug command inj_guest_exp
inj_guest_exp can be used to inject a virtual exception to a
specified vcpu of a vm. The command format is as follows:
inj_guest_exp <vm id, vcpu id, exception_num>

Tracked-On: #6468
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
2021-08-25 11:41:36 +08:00
Minggui Cao
8ae4c90747 hv: dbg: sample vmexit data per-pCPU and per-vCPU
this feature is used to sample vmexit data per physical CPU
and per virtual CPU of VM, command used in HV console as following:
  1. vmexit clear --> to clear current vmexit buffer
  2. vmexit -->output current vmexit info
  3. vmexit enable | disable, by default enabled.

Tracked-On: #5232
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2021-08-20 14:16:33 +08:00
Junjie Mao
b3767a4a32 config_tools: rename two missed PSRAMs to SSRAMs
The term PSRAM is now obsoleted and should be replaced with SSRAM, as has been
done by commit 9facbb43b3 ("config-tool: rename PSRAM to SSRAM"). However,
there are two places in the configuration toolset that still uses PSRAM. This
patch updates these missed occurrences accordingly.

Tracked-On: #6012
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-20 11:09:36 +08:00
Minggui Cao
fc99b69e17 hv: expose PMC to core partition VM
for core partition VM (like RTVM), PMC is always used for performance
profiling / tuning, so expose PMC capability and pass-through its MSRs
to the VM.

Tracked-On: #6307
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-08-19 19:02:33 +08:00
Minggui Cao
a7b7b9d864 hv: use ARRAY_SIZE to calc local array size
if one array just used in local only, and its size not used extern,
use ARRAY_SIZE macro to calculate its size.

Tracked-On: #6307
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2021-08-19 19:02:33 +08:00
Jian Jun Chen
9d650ccdf0 hv: ivshmem: map SHM BAR with PAT ignored
ACRN does not support the variable range vMTRR. The default
memory type of vMTRR is UC. With this vMTRR emulation guest VM
such as Linux refuses to map the MMIO address space as WB. In
order to get better performance SHM BAR of ivshmem is mapped
with PAT ignored and memory type of SHM BAR is fixed to WB.

Tracked-On: #6389
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2021-08-16 10:29:20 +08:00
Yonghua Huang
2205dd393a 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-16 10:23:37 +08:00
Yang,Yu-chu
fc60a200d0 config-tools: refine the MAX_MSIX_TABLE_NUM in config.h
Find the maximum of counts MSI and table_size of MSI-X based on
board.xml.

Tracked-On: #6235
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-08-12 10:53:33 +08:00
Yang,Yu-chu
2183f308b4 config-tools: add MSI-X capability
Add the MSI-X capability structure nodes under <capability
id="MSI-X"> in board.xml.
Example:
  <capability id="MSI-X">
    <table_size>16</table_size>
    <table_bir>1</table_bir>
    <table_offset>0x1000000</table_offset>
    <pba_bir>1</pba_bir>
    <pba_offset>0x0</pba_offset>
  </capability>

Fix the MSI <count> nodes when there is only one vector.

Tracked-On: #6235
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-08-12 10:53:33 +08:00
Kunhui-Li
5ce22d1649 config_tools: update board xml files for MAX_MSIX_TABLE_NUM fix
The PR 6236 has modified the board.xml format for MAX_MSIX_TABLE_NUM fix.
To compromise this PR, updates all the source file board.xmls.

Tracked-On: #6235
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-12 10:53:33 +08:00
Yifan Liu
4e77dcfba1 hv: Squash warning of code scanning tool
The original use of recalc_checksum(eps->int_anchor, ...) may cause
an array bound overflow warning from code scanning tool. This patch
changes it to use offsetof to avoid using int_anchor directly.

Tracked-On: #6383
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-08-12 09:59:51 +08:00
Fei Li
7dd877f8eb hv: fixup: a minor refine about tpm2_fixup
Check the return value of get_mod_by_tag before use it.

Tracked-On: #6380
Signed-off-by: Fei Li <fei1.li@intel.com>
2021-08-12 09:45:52 +08:00
Victor Sun
e5aa63b08e config_tools: update ehl-crb-b xml with new uart
The debug uart of mmio@0xfe042000 has been switched to pci uart at 0:19.2,
so change the board file accordingly.

Tracked-On: #6348

Signed-off-by: Victor Sun <victor.sun@intel.com>
2021-08-04 09:13:35 +08:00
Victor Sun
f5594a0ddc HV: debug: support 64bit BAR pci uart with 32bit space
Currently the HV console does not support PCI UART with 64bit BAR, but in the
case that the BAR is in 64bit and the BAR space is below 4GB (i.e. the high
32bit address of the 64bit BAR is zero), HV should be able to support it.

Tracked-On: #6334

Signed-off-by: Victor Sun <victor.sun@intel.com>
2021-08-02 16:49:37 +08:00
Yifan Liu
8cb18fb6fd hv: SMBIOS: add check before SMBIOS probing
The SMBIOS passthrough is supposed to work under UEFI environment.
Previous patches assumes UEFI environment but it may cause problems on
some platforms. This patch adds checking before probing SMBIOS table to
avoid this problem.

Tracked-On: #6345
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-08-02 16:07:43 +08:00
Fei Li
89c25b008a hv: vpci: modify Interrupt Line Register as writable
According to PCIe Spec, for a RW register bits, If the optional feature
that is associated with the bits is not implemented, the bits are permitted
to be hardwired to 0b. However Zephyr would use INTx Line Register as writable
even this PCI device has no INTx, so emulate INTx Line Register as writable.

Tracked-On: #6330
Signed-off-by: Fei Li <fei1.li@intel.com>
2021-07-29 17:18:19 +08:00
Fei Li
9948dea338 hv: relocate ACPI DATA address to 0x7fe00000
Relocate ACPI address to 0x7fe00000 and ACPI NVS to 0x7ff00000 correspondingly.
In this case, we could include TPM event log region [0x7ffb0000, 0x80000000)
into ACPI NVS.

Tracked-On: #6320
Signed-off-by: Fei Li <fei1.li@intel.com>
2021-07-29 15:52:56 +08:00
Tao Yuhong
2e5aa8be99 HV: MMIODEV: delete memory resource before add it to pre-launched VM
If mmio resource is included in ACPI DATA e820 entry, it is will be
mapped to RAM first. Then pre-launched VM can't map mmio resource GPA
to its MMIO HPA.

Tracked-On: #6320
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-07-28 13:54:22 +08:00
Junjie Mao
48c070c88e config_tools: adjust the end of TPM log area
The log area of TPM is typically placed as part of the ACPI data region in
e820. This patch follows this convention by adjusting how the virtual TPM
log area base address is allocated.

Tracked-On: #6320
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-28 13:52:12 +08:00
Kunhui-Li
2db0b235b7 config_tools: enlarge max size to store RTCT table
Enlarge the max size to store the PTCT/RTCT table to 1k bytes
because the size of RTCT table exceeded the original max size
0x1100 - 0xF00 which makes RTCT table overlap other ACPI tables.

Tracked-On: #6303
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-07-28 13:50:16 +08:00
Yifan Liu
9fbef0df69 config-tools: Update tgl-rvp.xml
Update tgl-rvp.xml to latest version.

Tracked-On: #6320
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Yang,Yu-chu
dce3142cfc config-tools: refine bin_gen.py arguments and tpm2_acpi_gen
Refine the arguments of bin_gen.py. The --board and --scenario take the
path to the XMLs as the argument. The allocation.xml is needed for
bin_gen.py to generate tpm2 acpi table.

Refine the condition of tpm2_acpi_gen. The tpm2 device "MSFT0101" can be
present in device id or compatible_id(CID). Check both attributes and
child node of tpm2 device.

Tracked-On: #6320
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
7439ac1a92 board_inspector: extract Compatible IDs of devices
In addition to the mandatory _HID (Hardware ID), the ACPI spec also defines
an optional _CID (Compatible ID) object for device identification.

This patch enhances the ACPI extractor by parsing the _CID objects of devices as
well.

Tracked-On: #6320
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Yifan Liu
6030211122 hv: SMBIOS passthrough for prelaunched VM
This patch passthrough native SMBIOS information to prelaunched VM.
Currently this is enabled by default, the config-tool switch will be
added later.

Tracked-On: #6320
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-07-26 16:51:30 +08:00
Yang,Yu-chu
796f11a064 config-tools: create virtual acpi of passthrough tpm2
Create virtual acpi table of tpm2 based on the raw data if the tpm2
device is presented and the passthrough tpm2 is enabled.

Tracked-On: #6320
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-26 16:51:30 +08:00
Yang,Yu-chu
2940b8a31e config-tools: generate the log area data of tpm2
Insert the passthrough tpm2 datas to mmiodevs of vm_configurations.c

Tracked-On: #6320
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-26 16:51:30 +08:00
Yang,Yu-chu
15fa9f95ca config-tools: allocae log area start address
If passthrugh TPM2 is enabled and the log area is present, allocates
the log_area_start_address with the size log_area_minimum_length(256K).

Tracked-On: #6320
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-26 16:51:30 +08:00
Yang,Yu-chu
40eaff9569 config-tools: add tpm2 acpi parser to board_inspector
Create python script tpm2 which parse the tpm2 acpi table datas. Add
this parsed data to the <device id="MSFT0101" description="TPM 2.0 Device"> of board.xml.

Tracked-On: #6320
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
3c707408ec board_inspector: check if BAR base is 0
It is seen occasionally that a memory/port BAR of a PCI device is
programmed with the address 0 which is clearly invalid. This patch
gracefully handles this case by printing an error to warn the users that
this device cannot be passed through to any VM.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
7f3016e678 board_inspector: fix scope opening in the AML parser
According to section 19 of ACPI spec 6.4, the following clauses open name
scopes (in addition to the Scope clauses).

  - Function
  - Device
  - Method
  - Power Resource
  - Thermal Zone

The current AML parser only opens a scope when parsing DefMethod and
DefDevice, however. This patch fixes the AML parsing by opening a scope on
visiting a DefPowerRes or DefThermalZone clause.

Note: Functions in ASL are equivalent to Methods at AML level.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
a65d162b15 board_inspector: fix unregisteration of conditionally disabled objects
The current ConditionallyUnregisterSymbolVisitor has the following two
issues.

  1. The visitor will crash when a DefIfElse node is not fully parsed due
     to failed deferred expansion.
  2. Nested DefIfElse of disabled blocks are still checked and one of its
     branch may still take effect.

This patch fixes those issues by checking the predicates of a DefIfElse
block only when conditionally_hidden is False and check existence of
TermList and DefElse clauses.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
631d628178 board_inspector: fix an opcode peek issue
When parsing a sequence of clauses, it is not necessary to peek an opcode
from the current stream unless that sequence starts with one. Peeking an
opcode is even an error when the actual clause is empty (e.g. as a
TermList).

This patch makes the SequenceFactory only peeking at the next opcode when
the grammar expects one.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
60da7d6bfd board_inspector: improve readability and performance of AML parser
This patch refines the AML parser to improve its readability and
performance in the following ways.

  1. A Tree object now has the parts of the corresponding object being
     member fields. As an example, a Tree with label `DefMethod` now has
     members `NameString`, `MethodFlags` and `TermList`.
  2. It is now possible to assign names each part of an object. The grammar
     is updated to assign different names to the parts with the same type
     in the same object.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
6e79479a0a board_inspector: always defer parsing of method bodies
The current ACPI AML parser can generate incorrect AST if a DSDT/SSDT
satisfies the following:

  1. The body of a method invokes a NameString that is defined later.
  2. Before the method that NameString is also defined but in an outer
     scope and with a different number of parameter.

Since method bodies hardly define any further symbol that is referenced
outside the method itself, this patch forces the parsing of method bodies
to be deferred to the second pass when all symbols have been declared.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
0395a8adf9 board_inspector: Access I/O registers on-demand and properly
The current implementation of I/O buffers have the following issues.

  1. I/O buffers are filled with values on creation. This may be fine for
     memory-mapped I/O regions, but could be a problem to port I/O regions
     and indexed I/O regions.

  2. While not commonly seen, it IS witnessed that some devices only allow
     its MMIO registers to be accessed with certain width. Accessing such
     registers with a larger width will not be handled by the device,
     causing SW to get all 1's rather than the actual values in these
     registers.

This patch resolves the issues above as follows. I/O buffers now do not
access any register on creation. Instead, the register is accessed only
upon requests. Also the access width of these registers are followed to
ensure that the registers are accessed properly.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
6f3bfa80b1 board_inspector: interpret DefDivide in DSDT/SSDT
DefDevide is now enountered when interpreting host DSDT/SSDT. This patch
implements the interpretation.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Junjie Mao
d333ae50d7 board_inspector: return from method call invocation on DefReturn
The current implementation of the AML interpreter continues interpreting a
method after meeting a DefReturn object, which is incorrect. This patch
fixes this issue.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-07-26 16:51:30 +08:00
Tao Yuhong
ab82f67cb9 HV: TPM: check tpm2 start method and event log
If TPM device is passthrough to pre-launched VM, need check its
start method and event log settings in native TPM2 ACPI table.
Because when connect different TPM devices, TPM start method can
change in native ACPI table. And event log address change in native
ACPI table is expected by BIOS updating. Need fixup pre-launched
VM's ACPI table and vm_config if they are misaligned with native
platform. We add acrn_vm_fixup() in prepare_vm(), where the acrn_vm
structure is not created. This is suitable for checking between
vm_config and HW real configurations, and try fixup for native ACPI
updating.

Tracked-On: #6320
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-07-26 16:51:30 +08:00