Commit Graph

795 Commits

Author SHA1 Message Date
Shiqing Gao de19301a5a config_tools: refine the configuration data description
This patch refines the configuration data description so that it is
consistent with the current implementation of the configuration tools.

Tracked-On: #6377

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2021-08-11 16:38:35 +08:00
Fei Li 3df703a64e config-tools: add SECURITY_VM_FIXUP config
Add SECURITY_VM_FIXUP config for Security VM whether it needs to do fixup
for TPM2 and SMBIOS

Tracked-On: #6320
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Fei Li <fei1.li@intel.com>
2021-08-11 14:45:55 +08:00
Yang,Yu-chu d997f4bbc1 config-tools: refine bin_gen.py and create virtual TPM2 acpi table
Create virtual acpi table of tpm2 based on the raw data if the TPM2
device is presented and the passthrough tpm2 is enabled.

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-08-11 14:45:55 +08:00
Yang,Yu-chu 53d99d2a68 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-08-11 14:45:55 +08:00
Yang,Yu-chu cb736e4cc1 config-tools: allocate log area start address
If passthrough 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-08-11 14:45:55 +08:00
Yang,Yu-chu f3125e58ed 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-08-11 14:45:55 +08:00
Fei Li a705ff2dac 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-08-11 14:45:55 +08:00
Fei Li 74e68e39d1 hv: tpm2: do tpm2 fixup for security vm
ACRN used to prepare the vTPM2 ACPI Table for pre-launched VM at the build stage
using config tools. This is OK if the TPM2 ACPI Table never changes. However,
TPM2 ACPI Table may be changed in some conditions: change BIOS configuration or
update BIOS.

This patch do TPM2 fixup to update the vTPM2 ACPI Table and TPM2 MMIO resource
configuration according to the physical TPM2 ACPI Table.

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
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
Kunhui-Li 54fe6f900b config_tools: update launch xml for only one NVME
Update launch xml to use image to launch hard rt vm since
we changed the platforms from two disk to only one NVME disk.

Tracked-On: #6315
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-11 11:49:17 +08:00
Kunhui-Li 158eb38280 config_tools: update lpc slot number
Update lpc slot to origin value 1 from 31 because GOP driver has assumption
to config space layout of the device on 00:1f.0.

Tracked-On: #6340
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-11 08:57:37 +08:00
Kunhui-Li 03fca4463c config_tools: remove adl-rvp
remove adl-rvp folder.

Tracked-On: #6315
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-10 15:29:51 +08:00
Yang,Yu-chu 9b52d75262 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-08-10 13:16:36 +08:00
Junjie Mao 185b5d22e2 board-inspector: support buffer assignments and indexing
The ACPI specification allows both assigning to buffers and indexing to a
certain byte of a buffer using the Index operator. This patch adds the
implementation of these two operations in the interpreter.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-10 08:36:24 +08:00
Junjie Mao 50cd8e2558 board-inspector: fix the creation of packages
The PackageElementList builder takes variadic arguments, each of which is
an element of the package to be created, not a single argument being the
list of the elements. This patch fix the call to PackageElementList in
build_value() where the wrong type of argument was passed.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-10 08:36:24 +08:00
Junjie Mao 065316ba1e board-inspector: use the same _MIN and _MAX for 0-length regions
It is typical in AML resource descriptors to have 0-length region
descriptors which are typically templates of resources that are not
assigned on the current platform. For such regions, the `base + length - 1`
formula does not calculate the max of the region properly.

This patch updates the resource descriptor parsers to use max = min when
the length of the region is 0.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-10 08:36:24 +08:00
Junjie Mao bcc8358d93 board-inspector: fixes to issues when parsing host-bridge objects
When parsing an AML object representing a host bridge, the current board
inspector may encounter the following issues:

  1. The host DSDT may contain multiple host bridge instances, with some of
     them not being present. In this case the _BBN of these instances may
     evaluate to the same value that coincide with the bus assigned to an
     existing host bridge, leading to multiple PCI bus nodes with the same
     bus number and thus confusion in later information extraction phases.

  2. Methods of a host bridge may refer to the PCI configuration space of
     itself (which is typically Device 0, Function 0 under that
     bus). However, such objects may not have an _ADR object as the bus
     number is encoded by the _BBN object instead.

This patch fixes the issues above.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-10 08:36:24 +08:00
Junjie Mao 1e3b2a00b9 board-inspector: add interpretation of OnesOp, DefMatch and DefSizeOf
This patch enables the interpretation of the following AML objects.

  * OnesOp. A OnesOp object always evaluates to a 64-bit integer with all bits
    set to 1. It is assumed that the host DSDT is always revision 2 or above,
    which is typically the case on modern platforms.

  * DefMatch. A DefMatch object evaluates to the index of the first
    element (starting from a given index) in a package that matches the given
    two predicates. If a match is not found, the constant Ones is returned.

  * DefSizeOf. A DefSizeOf object evaluates to the byte length of a buffer, the
    length of a string (without the terminating NUL character) or the number of
    elements in a package.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 13:59:16 +08:00
Junjie Mao 4cb0d95fc0 board_inspector: try mroe type convertions when evaluating branch conditions
In commit e5ba06cbe8 ("board_inspector: a workaround to an incorrect
interpretation") a workaround is introduced to check the data type of
predicate operands. That commit assumes that both operands must be exactly
integers, which is not usually the case as operation fields or strings can
also be used in predicates.

This patch applies the following conversions on both operands when
evaluating a predicate:

  1. Try converting both operands to integers

  2. If either conversion in step 1 fails, try regarding both operands as
     strings.

  3. If either operand is not a string, return the default
     result (i.e. False).

Fixes: e5ba06cbe8 ("board_inspector: a workaround to an incorrect interpretation")
Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 13:59:16 +08:00
Junjie Mao 25cabe14db board-inspector: replace enter_scope with change_scope
The method `enter_scope` of class `Context` is a reduced implementation of
`change_scope` which assumes that the given name is simply a NameSeg. This
method is currently only used when a new named scope is opened by a
DefDevice object for historical reasons.

As the other named-scope-opening objects all use `change_scope` which can
handle arbitrary NameString, this patch unifies the code by removing
`enter_scope` and replacing the only occurrence with `change_scope`. This
also resolves the parsing of AML templates in board XMLs where device names
can be more than a simple NameSeg.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 13:59:16 +08:00
Kunhui-Li 578c18b962 config_tools: remove obsolete kconfig files
Remove obsolete Kconfig files;
Update Kconfig related README and error message.

Tracked-On: #6315
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-09 09:25:02 +08:00
Junjie Mao 2dd9ec8612 board_inspector: do not use _MAX as the end of a memory region
According to the specification, the _MAX of memory address space resource
descriptors may not necessarily be _MIN + _LEN - 1. Typically the resource
locates at the low end of the region specified by _MIN and _MAX. This patch
makes the ACPI extractor always calculating the end of a memory region
using _MIN and _LEN instead.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao e5ba06cbe8 board_inspector: a workaround to an incorrect interpretation
The current design of AML parsing, objects are first defined in the
namespace and later dropped if they are in a False branch. This leads to
incorrect interpretation of the AML code where:

  1. A name T is defined in the root scope as an integer.

  2. A method M in an inner scope S references T.

  3. The name T is defined as a device, power resource or other named
     objects in scope S under conditions where M will not be called.

As a workaround, check if both the left and right hand sides are integers
first. If either is not the case,

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao d2543720a5 config_tools: adjust the layout of vACPI images
The current vACPI image layout reserves 512 bytes for vDSDT. Given the fact
that the size of vDSDT of a pre-launched VM grows when more devices are
assigned to the VM, this size limit can be easily exceeded. As an example,
a single pass-through TSN NIC requires 291 bytes in vDSDT to define device
objects representing its PCS (Physical Coding Sublayer), which means the
current reserved space for vDSDT does not allow two TSN NICs to be assigned
to the same VM.

This patch enlarges the reserved space for vDSDT to 2432 bytes by moving
the MCFG and MADT spaces. 768 bytes are still reserved for MADT which
is sufficient to encode the LAPIC information for more than 64 vCPUs.

This patch is added in v2 of the series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 07c2f604ae config_tools: generate vDSDT according to allocated resources
This patch generates vDSDT for pre-launched VMs based on the scenario
configuration and static allocation results. The vDSDT contains the
following objects.

  * A device object representing the root PCI bus which has the same
    location and name as the object in physical DSDT. This object contains
    device identification objects such as _HID, _CID, _BBN and _UID, the
    _CRS object encoding the bus numbers and PCI hole regions, and the _PRT
    object encoding the routing from vPCI device pins to virtual interrupt
    lines.

  * For each pass-through device assigned to the VM, a device object is
    created based on the AML template of that device in board XML (if
    exists). The _ADR object is rewritten with the vBDF..

v1 -> v2:
  * In order to replace the current static vDSDT, the AML templates in
    board XMLs now include objects that are referenced by other devices as
    well.
  * When TPM is assigned, the corresponding device object in DSDT (if
    exists) will be copied.
  * Add the _S5 control method to vDSDT, as is done in the static DSDT
    sources.
  * The old vDSDT generation routine and the static DSDT sources it uses
    are removed.

v2 -> v3:
  * Only follow 'uses', 'is used by' or 'consumes resources by'
    dependencies.
  * Organize the device objects in vDSDT according to the scopes they are
    in.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 5c34fd0c56 config_tools: allocate interrupt lines among VMs
This patch allocates interrupt lines among VMs according to the PCI devices
assigned to them.

v1 -> v2:
  * Remove the usage of VMx_PT_INTX_NUM macro in vm_configuration.c; use the
    concrete numbers directly.
  * The static allocator will also complain if any interrupt line is allocated to
    a VM with LAPIC_PASSTHROUGH.

v2 -> v3:
  * Fix a minor coding style issue.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 692ab1d529 config_tools: abstract BusDevFunc to the common library module
It is a common practice to parse PCI BDF in the static allocators. This
patch moves the BusDevFunc class (which is a named tuple encoding a BDF) to
lib.py and uses it for BDF parsing throughout the static allocators.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao edfac3ce62 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-08-09 09:05:01 +08:00
Junjie Mao 5223433a38 board_inspector/cli: replace `--advanced` with `--basic`
With a growing demand on host ACPI namespace for devices pass-through, it
is now important to parse the ACPI namespace when generating board
XMLs. This patch makes ACPI namespace parsing enabled by default by
replacing the `--advanced` option, which is designed to enable the parsing,
to `--basic` which disables it.

The option provides a reliable way to disable ACPI namespace parsing
completely in case the parsing blocks the generation of board XMLs, while
the ACPI namespace parser will gracefully stop without polluting the board
XML when it fails.

This patch is added in v2 of the patch series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 0f4275b041 board-inspector: collect address bits of processors
This patch updates the board inspector to collect the bits of physical and
linear addresses of the processors and generate this information to the
board XML for further uses at configuration phase.

Tracked-On: #6292
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 3b41713c7e board_inspector: make filtering by device status optional
It is witnessed on some boards that the device status (as is reported by
the _STA object) returns 0 while the device object is still useful for
pass-through devices. The original implementation, however, assumes that
only a device is a non-zero status is useful as long as the _STA object
exists.

This patch makes this filtering disabled by default and adds a command-line
argument `--check-device-status` to enable this filtering. As disabled or
non-present devices can have empty resources, the sorting algorithm is
updated accordingly to gracefully handle such descriptors.

This patch is added in v3 of the series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 5d44640515 board_inspector: add conversion to hex string from buffer fields
Occasionally buffer fields (which are typically integers) are converted to
hexadecimal strings for debugging purposes. This patch adds the conversion
to suppress interpretation errors of these debugging calls.

This patch is added in v3 of the series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao d66c62aad1 board_inspector: scanning all peer root hostbridges in domain 0
Servers typically have multiple peer host bridges that need to be scanned
separately. This patch extends the PCI information extractor to visit all
PCI host bridges by enumerating /sys/devices/pci* directories.

Tracked-On: #6292
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao ae496de9d8 board_inspector: allow ConstObj to be used as a TermObj
While not allowed by ACPI specification, using a ConstObj (e.g. OneOp) as a
term in a TermList IS witnessed in the DSDT of some BIOS. This patch allows
ConstObj to act as a TermObj so that a TermList can contain a ConstObj as a
statement (which is essentially no-op).

This patch is added in v2 of the series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 6be3f93173 board_inspector: resume a device if it is not in D0
It is seen that the BAR in the PCI configuration space of a device can be
cleared when the device is put to D3. This patch resumes a device not in D0
before parsing its configuration space in order to collect accurate
information.

This patch is added in v2 of the series.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao d6e47bcea5 board_inspector: collect inter-device dependency in board XMLs
AML allows devices defined in an ACPI namespace to have inter-dependency,
i.e. a method defined in one device can refer to objects in other
devices. While such inter-dependency is common in device manipulation
methods, device identification and configuration methods, such as _CRS, may
depend on other devices as well.

An example we have already met is a PCS (Physical Coding Sublayer) which
calculates resource descriptors by accessing the PCI configuration space of
the accompanying Ethernet controller. Without the ACPI object describing
the PCS, a driver of the Ethernet controller may refuse to initialize.

This patch adds a preliminary dependency analyzer to detect such
inter-device dependency. The analyzer walks through the reference chains of
an object, identifying whether the referenced objects are operation fields
of a device. Depending on the result of this analysis, the board XML is
refined as follows.

  * When an object (probably a method) references such fields, the original
    object definition in host DSDT/SSDTs will be copied in the AML template
    so that they still work in VMs where the operation fields may be
    virtualized. Such objects will be referred to as "copied objects"
    hereinafter.

  * The objects that are **directly** referenced by a copied object is
    added in the AML template as well. Such objects still belong to devices
    where they are originally defined in the host ACPI namespace. Their
    definition, however, may be copied or replaced with constant values,
    depending on the dependency analysis on these objects.

  * Nodes with the "dependency" tag are added under "device" nodes in the
    board XML, allowing the configuration tools to follow the device
    dependency chain when generating vACPI tables. These nodes only
    represent direct dependencies; indirect dependencies can be inferred by
    following those direct ones.

The current implementation does not allow objects being added to AML
templates if they refer to any of the following.

  * Global objects, i.e. objects not belonging to any device. Such objects
    tend to encode system-wide information, such as the ACPI
    NVS (Non-Volatile Storage) or its fields.

  * Methods with parameters.

Objects with such references are thus being hidden from guest software,
just like how they are invisible in the current implementation.

This patch is added in v2 of the series.

v2 -> v3:
  * Also collect dependencies due to providing or consuming resources.
  * Refactor the dependency detection logic for clarity.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao a2e9a05737 board_inspector: add GPIO and generic serial connection parsers
GPIO and generic serial connection resources in ACPI resource descriptors
usually encode resource sources which are important in detecting
cross-device dependencies. This patch adds parsers for GPIO and generic
serial connection descriptors.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 52c3ed7e09 board_inspector: add AML templates to board XML
This patch adds AML template (in XML hexBinary format) for each device to
board XMLs. For now these templates contain the following objects if they
exists in the physical DSDT:

  - Device identification objects: _ADR, _HID, _UID and _STR
  - _CRS which encodes the current resources consumed by the device
  - _STA which encodes the status of the device

An AML template is always a DefScope with a single DefDevice so that they
can be appended anywhere in the vDSDT.

v1 -> v2:
  * Remove the temporary visitor that collects cross-device dependencies. Such
    check will be replaced with another visitor introduced in the next patch.

v2 -> v3:
  * The AML templates are now DefDevice objects with their names being the
    full namepath. The vDSDT generator will take care of this and organize
    the objects properly.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 6ccd7660a4 board_inspector: add object_type codes in Decls
Object type codes are used to identify, as the name suggests, type of
objects. Typical object types in AML include integers, strings, methods,
devices, buffers, packages and operation regions. In DefExternal terms the
object type codes help specify the type of the external objects so that an
AML parser can parse the code without knowing the concrete definition of
these objects.

The per-device AML templates in board XMLs need DefExternal terms to
declare the objects in other devices, as these templates are meant to be
parsed and integrated separately. This patch adds a static method to object
declaration classes to make it easier to generate such DefExternal terms
for a given declaration.

A complete definition of object type codes can be found in section 19.6.96
of ACPI specification 6.4.

v1 -> v2:
  * Remove the object_type of FieldDecl and OperationFieldDecl as 0x5 is
    not a proper object type for buffer fields.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao d58ef5e2aa board_inspector: skip visiting DefMethod properly when unregistering symbols
The current implementation of the ConditionallyUnregisterSymbolVisitor
exits upon visiting a DefMethod node without unregistering that method. As
a result, methods in False branches in DSDT/SSDTs are not removed from the
parsed namespace, which can lead to further confusions when these methods
are referenced (e.g. a _CRS method visited by the board inspector).

This patch fixes this by always visiting a DefMethod node but stops
traversing its children.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 5ad06e933a board_inspector: also try /usr/share/pci.ids.gz for PCI ID lookup
/usr/share/pci.ids.gz is another typical path to the pci.ids file of the
lspci tool which is used in Yocto-based systems. This patch adds this path
as another candidate when searching for pci.ids. The builtin gzip module is
used to open this file.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 1e092a89d6 board_inspector: add default value to address space descriptors
Address space resource descriptors have an optional field to encode the
resource source, which is not commonly used when creating new resource
descriptors.

For modules which want to create a class to parse address space resource
descriptors without resource source, this patch sets the length of such
descriptors as the default value of the `_len` factory parameter so that
callers do not need to care about these lengths.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 5cf9ac714c board_inspector: extend DSDT parser to allow parsing arbitrary trees
With AML templates for devices in the board XML, the parser now needs to be able
to parse a stream as an arbitrary object. This patch adds the `parse_tree`
method to the acpiparser.aml.parser module for this purpose.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 94d517b514 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-08-09 09:05:01 +08:00
Junjie Mao 879c6c11ca board_inspector: more verbose messages
It is quite common to meet permissions errors when opening a specific
region of /dev/mem due to kernel configurations. This patch adds a bit more
logs on this for eaiser debugging.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 26021bd467 board_inspector: add interrupt pin routing and usage
This patch adds interrupt pin related information into the board XML,
including:

  * The PCI routing table in ACPI DSDT/SSDT are parsed and generated into
    the board XML as "interrupt_pin_routing" nodes.

  * IRQs encoded in _CRS directly are represented as resources of type
    "irq".

  * Interrupt lines (i.e. INTx#) of PCI devices are represented as
    resources of type "interrupt_pin". When the PCI routing table is
    available, the corresponding interrupt line is identified and
    represented as the "source" attribute of the resource node.

Due to the existence of vIOAPIC in ACRN VMs, the board inspector interprets
the \_PIC method with parameter 1 to inform the ACPI namespace that the
interrupt model should be in APIC mode.

v1 -> v2:
  * Remove the msi_enable variable which is defined but never used.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao a3aa0797b1 board_inspector: add builders of AML AST nodes
This patch adds the acpiparser.aml.builder module which provides methods to
construct AML trees from scratch in Python. Similar to how parsers and
binary generators are implemented, this module constructs most builder
methods from the AML grammar defined in the acpiparser.aml.grammar
module. AML objects whose grammar are not present in the grammar module
require special treatment and their builders are implemented
explicitly. The methods have the same name as the AML tree labels defined
in the grammar.

In addition, this module also provides the method `build_value` which
converts plain integers, strings or interpreter values (which are defined
in the datatypes module) to AML trees.

With the builders, the `interpret_method_call` method in the
ConcreteInterpreter is refined to build the (fake) MethodInvocation node
using the builders and handle the actual parameters as well.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao e91ace7341 board_inspector: refactor tree visitors and transformers
Tree visitors usually have a fixed direction (either top-down or bottom-up)
and invoking a visitor with a wrong direction typically leads to unintended
behavior. However, the current implementation exposes both `visit_topdown`
and `visit_bottomup` methods to users, allowing callers to invoke the
visitors in an undesigned way. The same issue exists in the implementation
of transformers.

This patch refactors the base classes of visitors and transformers so that
they require an explicit direction from their sub-classes to
initialize. Callers of the visitors and transformers are now expected to
invoke the `visit` or `transform` methods without assuming the correct
direction of the visitor or transformer. The original `visit_topdown` or
`visit_bottomup` methods (or their transformer counterparts) are now
used to initialize the `visit` method and can be used by the subclasses in
case those subclasses visits the tree in a customized manner.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 55554e7d56 board_inspector: add a visitor to generate AML binary from trees
This patch introduces a visitor that converts an arbitrary AML tree to an
AML binary. Most nodes can be converted in a straightforward way by
following the defined grammar, but the following nodes require some
additional effort:

  - NameStrings can be formatted as either a NameSeg (i.e. four upper case
    characters), a DualNamePath, a MultiNamePath or a NullName.

  - PkgLengths are recalculated according to the actual length of the
    following object (in case they are changed dynamically after being
    generated by the parser) and generated following the AML encoding of
    such lengths.

The visitor works in a bottom-up manner, i.e. the children are visited and
converted to binary before the parent.

The whole trees parsed from DSDT/SSDTs are now also stored in the Context
for further reference.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao b119a0b824 board_inspector: collect descriptions of ACPI devices
_STR is another device identification object defined in ACPI spec that
describes a device. This patch collects this string (when available) into
board XML as well.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 127e12a56a board_inspector: add a property to reflect the encoded IRQs in RDT
This patch adds the property `irqs` to the class SmallResourceitemIRQ so
that the list of IRQs encoded in this resource item can be retrieved
easily.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 0991f7f03b board_inspector: add a parser of PCI routing tables
This patch adds a parser to the PCI routing tables returned by _PRT objects
of platform devices. The parsed result is a list of PRTMappingPackage
instances, each of which is a named tuple with the following fields:

  * address: a dword with higher 16 bits being the function number and
    lower 16 bits all 1's.
  * pin: a byte representing the mapped pin.
  * source: either a DeviceDecl of the device that allocates the interrupt
    line, or the byte 0.
  * source_index:
    - If `source` is a DeviceDecl, this is the index of the interrupt
      source within that device.
    - If `source` is 0, this is the interrupt line connected to the pin.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 503b1ee317 board_inspector: fix returning nested local variables
Local variables can be assigned with formal arguments in AML. As a result
when interpreting a DefReturn node, the interpreter shall unwrap multiple
layers of argument/local variable wrappings until a concrete value is
found. This patch implements this logic.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 0b46440b32 board_inspector: strip an end tag when concat resource templates
Resource template buffers always end with an end tag. Concatenation of two
resource buffers thus requires that the end tag of the first buffer is
stripped. This patch adds this logic to the interpretation of DefConcatRes
AML nodes.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 774b60ac2d board_inspector: adjust logging levels
The warning, info and debug logging levels are intended to be used in the
following way.

  * Warnings are used when users are expected to be aware of a certain
    failure.
  * Info messages are used to track parsing process and major internal
    errors for development.
  * Debug messages are used to collect verbose debug logs.

To align the current usage of logs to the above guidelines, this patch
adjusts the logging level of the following messages:

  * DSDT/SSDT interpretation failures are now warnings, not information
  * Failures of parsing deferred AML blocks are now information, not debug
    messages

The default log level when running `cli.py` is adjusted to WARNING as well,
as INFO is primarily used for development. A new command line option
`loglevel` is added to adjust the log level per user needs.

v2 -> v3:
  * Make address collisions in ACPI namespace as an info rather than a
    warning.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 523ce8ad31 board_inspector: Remove dead code in parser.py
A DualNamePath clause is a NamePath that only follows rootchar or
prefixpath. Thus, it is never necessary to check if a dot is necessary for
separating segments before a DualNamePath. This patch removes the code that
conduct that check.

Tracked-On: #6287
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao a39f2995ad 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-08-09 09:05:01 +08:00
Junjie Mao 1ad836e9a8 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-08-09 09:05:01 +08:00
Junjie Mao a5f5ed0865 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-08-09 09:05:01 +08:00
Junjie Mao 35edd7804a 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-08-09 09:05:01 +08:00
Junjie Mao 3bcb3146ad 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.

  3. Invocation to intermediate factories is now skipped. As an example,
     when parsing a ByteConst that acts as a ByteIndex, the original
     implementation invokes the following factories in sequence:

         ByteIndex -> TermArg -> DataObject -> ComputationalData -> ByteConst

     The factories TermArg, DataObject and ComputationalData does nothing
     but forward the parsing to the next-level factory according to the
     opcode of the next object. With this patch, the invocation sequence
     becomes:

         ByteIndex -> ByteConst

     i.e. ByteIndex directly passes to ByteConst which can parse the next
     opcode.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao d325966612 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 that method the same 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-08-09 09:05:01 +08:00
Junjie Mao 60920bb905 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:

  1. I/O buffers now do not access any register on creation. Instead, the
     register is accessed only upon requests.

  2. The access width of these registers are followed to ensure that the
     registers are accessed properly.

The classes that represents buffers when interpreting AML is also
refactored to abstract the common code that manages fields within
buffers. The class hierarchy now looks like this:

  BufferBase: Implement methods that registers, reads or writes fields
    Buffer(BufferBase): Implement memory buffer
    StreamIOBuffer(BufferBase): Implement I/Os available via /dev files
    IndexedIOBuffer(BufferBase): Implement I/Os via index/data registers

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao 8c63550eb7 board_inspector: interpret DefDivide in DSDT/SSDT
DefDevide is now enountered when interpreting host DSDT/SSDT. This patch
implements the interpretation of the integer division operation.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Junjie Mao e56eb6238d 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 by raising a dedicated exception on return and catching
that exception on the caller side.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2021-08-09 09:05:01 +08:00
Kunhui-Li e1da33b031 config_tools: update generic_board folder
Update generic_board/generic_code folder with compile result
on the nuc11tnbi5 platform.

Tracked-On: #6292
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-03 09:06:02 +08:00
Kunhui-Li c581d44414 config_tools: update generic_board folder
Update generic_board folder with nuc11tnbi5 xml files.

Tracked-On: #6292
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-08-03 09:06:02 +08:00
Shuang Zheng fdc4da5f72 config_tools: config editor creates default xmls for a new board
config editor creates the default scenario xmls and launch xmls
based on generic configs when users import a new board.

Tracked-On: #6208

Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
2021-07-30 09:32:52 +08:00
Shuang Zheng e775db23b1 config_tools: add interface to save config xmls to user defined path in config editor
add interface to save scenario xmls and launch xmls to user defined
path in config editor; move all config xmls and generated scripts
out of acrn-hypervisor.

Tracked-On: #6208
Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2021-07-27 14:55:46 +08:00
Yang,Yu-chu e235d68526 config-tools: add uclock GP switch
A switch to force disable GP for UC lock using scenario configuration.

Tracked-On: #6299
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-21 11:28:30 +08:00
Yang,Yu-chu fec1f87adc config-tools: do not exit when the board inspector runs in hypervisor
While running in a nested environment, such as qemu, parse the board
information should be allowed even it is not in a native environment.

Replace the error with warning message and does not exit the program.

Tracked-On: #6208
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-07-19 10:13:28 +08:00
Kunhui-Li 005dacbbae 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-19 10:11:11 +08:00
Kunhui-Li fb0a9ccb5e config_tools: update nuc11tnbi5 xml files
1. Update the vaule of the tag CLOS_MASK to 0xfffff according to board.xml
in all scenario xml files.
2. Replace industry_launch_2uos.xml launch file with industry_launch_6uos.xml.
3. Update logical_partition.xml file.
4. Remove hybrid_rt.xml file, then add a second POST_STD_VM in hybrid.xml and
add hybrid_launch_2uos.xml launch file correspondingly.

Tracked-On: #6244
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-07-19 10:08:40 +08:00
Yang,Yu-chu 73547471c7 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-07-19 10:00:40 +08:00
Yang,Yu-chu 987216fef0 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-07-19 10:00:40 +08:00
Kunhui-Li 6f083154b6 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-07-15 14:42:55 +08:00
Shuo A Liu 1bccfab3b6 config_tools: Use new HSM driver device node
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 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 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 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 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
Kunhui-Li a8ef428b4b config_tools: fix cpu offline issue in launch script
In launch script, update cpu offline method to fix the issue
that it isn't offline cpu on ADL-S board.

Tracked-On: #6266
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-07-02 13:56:37 +08:00
Kunhui-Li e6d447e462 config_tools: update board_inspector to copy RTCT file
1. Remove acpi_template/ehl-crb-b/PTCT and acpi_template/tgl-rvp/PTCT files.
2. Update board_inspector/legacy/acpi.py script to copy RTCT file.

Tracked-On: #6238
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-07-02 13:42:06 +08:00
Yifan Liu 4252bc247d misc: efi-stub: Set MOR bit before jumping to hypervisor
This patch sets the MemoryOverwriteRequestControl (MORCtrl for short)
EFI variable before jumping to hypervisor.

Setting variable MemoryOverwriteRequestControlLock (MORCtrlLock for
short) can also be enabled by manually adding -DMORCTRL_LOCK_ENABLED to
CFLAGS.

Setting MORCtrl indicates to the platform firmware that memory be
cleared upon system reset. Setting MORCtrlLock for the first time will
render both MORCtrl and MORCtrlLock to read-only, until next reset.

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu c2217aa5d4 misc: efi-stub: Implement modules loading in container
This patch implements the container_load_modules function.
This function loads multiboot modules following multiboot protocol.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu e0f69399ff misc: efi-stub: Implement boot image loading in container
This patch implements the container_load_boot_image function.
This function loads boot image following multiboot protocol.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu daa42752d2 misc: efi-stub: Add barebone container as an implementation of HV_LOADER
Previous patches introduces an abstract struct HV_LOADER to do two
things: load boot image and load boot modules. This patch provides an
implementation barebone of container. The implementation of critical
functions container_load_boot_image and container_load_modules will come
in coming patches.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu e32640aab6 misc: efi-stub: Add helper functions to parse/load ELF32 image
This patch adds a file containing some helper functions to load
or validate ELF32 images.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu 6cb667f137 misc: efi-stub: Add helper functions to search/parse multiboot1/2 headers
This patch adds a file containing some helper functions to search or parse
multiboot headers.

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu 8c45359170 misc: efi-stub: Prepare multiboot1 info for HV
This patch adds code to prepare multiboot1 info passed to hypervisor.

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu f3d1823754 misc: efi-stub: Prepare multiboot2 info for HV
This patch adds code to prepare multiboot2 info passed to hypervisor.
Currently we prepare only the following information to hypervisor:
    Boot command line
    Boot loader name
    Modules
    Memory Map
    ACPI table
    EFI64 system table
    EFI memory map

Tracked-On: #6241
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
2021-06-24 14:42:56 +08:00
Yifan Liu 52790b5c0e misc: efi-stub: Barebone efi-stub for secure boot
ACRN EFI application based on the legacy efi-stub code provides booting method
of HV on UEFI-BIOS without using the GRUB Bootloader. It is supposed to be used
for secure booting on certain platform. By means of that users can boot HV,
Service VM kernel, pre-launched VM kernel and its ACPI table binary packed in
the Slim Bootloader container boot image file format. ACRN EFI application has
additional dependencies to compile which are not listed in the existing ACRN GSG
doc. Since this is an optional feature but not all users need, it does not get
compiled by default to avoid causing any confusion for existing users. README
for how to use the feature will come later in a separated commit.

This patch adds barebone implementation of this efi-stub. The following
files are reused from a previous version of efi-stub without changes:
    efilinux.h, pe.c, stdlib.h

Other files contains stubbed functions, whose implementation will come
in coming patches.

Tracked-On: #6241
Signed-off-by: Toshiki Nishioka <toshiki.nishioka@intel.com>
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Co-developed-by: Yifan Liu <yifan1.liu@intel.com>
2021-06-24 14:42:56 +08:00
Kunhui-Li 25c677dc39 doc: fix documentation's issue
1. Update the necessary libraries to consistent with the "Build ACRN From Source"
document in the "Getting Started Guide" document.
2. Delete the related introduction with acrngt.conf and launch_uos_id1.sh files in
"Getting Started Guide" document.
3. Update WHL-IPC-I7 board's processor in Supported HW document.
4. Add cpu_affinity element's description in ACRN Configuration Data.
5. Update the description for shm_region in Launch XML format.
6. Update configurable/readonly attributes values.
7. Update the description for hv.CAPACITIES.MAX_MSIX_TABLE_NUM in schema/config.xsd.

Tracked-On: #5692
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-06-23 19:25:22 -07:00
Kunhui-Li 294f38212e config_tools: clean up the board folders
1. Remove apl-up2, apl-up2-n3350, apl-mrb, nuc6cayh board
   folders from the latest code base.
2. Copy tgl-rvp.xml to generic_board.xml.
3. Update the related documentation because we remove apl-up2,
   apl-up2-n3350, apl-mrb, nuc6cayh board folders.

Tracked-On: #6175

Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-06-20 14:36:34 -07:00
Kunhui-Li 4f1c042ec1 config_tools: update scenario xml
1. Update the value of the tag MAX_MSIX_TABLE_NUM from 64 to empty
for all scenario xml except ehl-crb-b board.
2. Update the value of the tag MAX_MSIX_TABLE_NUM to 96 for the
scenario xml on the ehl-crb-b board.

Tracked-On: #6186

Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-06-11 14:58:45 +08:00
Kunhui-Li da2663d70b config_tools: update scenario xml
Update the value of the tag MAX_PT_IRQ_ENTRIES from 64 to 128
in TGL-RVP scenario xml.

Tracked-On: #6185

Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
2021-06-11 14:58:45 +08:00
Yang,Yu-chu 19f8bd7a06 config-tools: allocate the first unused bar for vmsix
A vmsix supported passthrough device expects the first unused bar region
for vmsix. Pop the first unused_bar_index in gpa.py instead.

Reference code: init_vmsix_on_msi of hypervisor\dm\vpci\vmsix_on_msi.c

Tracked-On: #6192
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
2021-06-11 10:48:56 +08:00
Zide Chen cc45a94d82 config_tools: add the missing GUEST_FLAG_NVMX_ENABLED to common.py
Without this, the GUEST_FLAG_NVMX_ENABLED doesn't show up in the
drop-down list of "guest_flags" in the ACRN config GUI.

Tracked-On: #5923
Signed-off-by: Zide Chen <zide.chen@intel.com>
2021-06-11 10:34:48 +08:00
Kunhui Li 2ce0b38486 doc: update the content about generating board xml
Update the content about getting board xml from native
enviroment in acrn_configuration_tool.rst and README.

Tracked-On: #6134
Signed-off-by: Kunhui Li <kunhuix.li@intel.com>
2021-06-09 17:17:09 -04:00