Commit Graph

16 Commits

Author SHA1 Message Date
Chenli Wei 030b2f804c dm: fix the secure coding style violations
There was some secure coding style violations of virtio net and tmp,
this patch add some NULL check to fix these violations.

Tracked-On: #6690
Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
2022-08-02 18:01:24 +08:00
Ziheng Li eb8bcb06b3 Update copyright year range in code headers
Modified the copyright year range in code, and corrected "int32_tel"
into "Intel" in two "hypervisor/include/debug/profiling.h" and
"hypervisor/include/debug/profiling_internal.h".

Tracked-On: #7559
Signed-off-by: Ziheng Li <ziheng.li@intel.com>
2022-07-15 11:48:35 +08:00
Yifan Liu eafc5ff418 dm: Coding style fix: Handle failure of parsing /proc/iomem
In get_mmio_hpa_resource, although very unlikely, parsing
of /proc/iomem may fail. Handle the case of failure and exit early.

Tracked-On: #7593
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2022-06-14 12:54:25 +08:00
Geoffroy Van Cutsem 8b16be9185 Remove "All rights reserved" string headers
Many of the license and Intel copyright headers include the "All rights
reserved" string. It is not relevant in the context of the BSD-3-Clause
license that the code is released under. This patch removes those strings
throughout the code (hypervisor, devicemodel and misc).

Tracked-On: #7254
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2022-04-06 13:21:02 +08:00
Yifan Liu 496a653b0d dm: Fix potential overflow bug
Fix a potential overflow problem in get_more_acpi_dev_info where ch_read
might have a value greater than 32.

Tracked-On: #6769
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2021-11-04 10:34:13 +08:00
Yifan Liu 00631f113f dm: TPM2 passthrough for post-launched VM with eventlog support
This patch enables TPM2 passthrough to post-launched VM with eventlog
support.
User starts by providing command line "--acpidev_pt <TPM2_HID>",
of which the <TPM2_HID> will be searched from /proc/iomem for TPM2 buffer
start address and size. Furthermore, If TPM2 eventlog is supported,
TPM2 eventlog information will be retrieved from sysfs TPM2 table and
passed-through as well.

v4 -> v5:
move tpm2 related logic from acpi.c to tpm.c
multiple API rename

Tracked-On: #6686
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-10-20 12:15:37 +08:00
Yifan Liu ad5eb6e23d dm: Refine ACPI device passthrough framework
This patch refines the ACPI device passthrough framework by defining a
generic framework. Note that when user gives an HID by "--acpidev_pt
<HID>", the pt logic will go through all registered ops to see if
there's a match.

v4 -> v5:
parse_pt_acpidev/parse_pt_mmiodev -> create_pt_acpidev/create_pt_mmiodev
    (there were already "init_xxx" function present, so rename to
    create_xxx)
"super user" -> "superuser"
multiple API renames

Tracked-On: #6686
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-10-20 12:15:37 +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
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
Tao Yuhong ad53894fdb DM: TPM: tpm passthrough device must use fixed base GPA
The TPM driver will access some mmio registers using absolute address,
That means TPM base GPA must use same HPA value, when passthough it to VM

Tracked-On: #6126
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2021-07-05 13:18:29 +08:00
Tao Yuhong c2df3f7940 DM: mmio dev: remove hard code device index
mmio_devs[0] is hard code for acpidev_pt, and mmio_devs[1] for
mmiodev_pt. Use mmio_dev_idx as index of mmio_devs[], to remove hard
code.
Remove hpa, gpa, size information from mmio_dev_ops, add acrn_mmiodev into
mmio_dev, to record hpa, gpa and size information for each passthough
mmio device.

Tracked-On: #5913
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-05-18 15:49:30 +08:00
Tao Yuhong 12f5a78800 DM: mmio dev: allocate GPA resource for mmio device
The mmio devices use hard code GPA base, allocating GPA base resource
for them instead.

Tracked-On: #5913
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-05-18 15:49:30 +08:00
Tao Yuhong cb8a6a7514 DM: tpm: remove fixed value TPM_CRB_MMIO_ADDR
The GPA of TPM device has fixed value TPM_CRB_MMIO_ADDR, remove
TPM_CRB_MMIO_ADDR and allocate GPA base for TPM device

Tracked-On: #5913
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-05-18 15:49:30 +08:00
Tao Yuhong f1c2eca1dc DM: support mmio dev gpa resource allocation
The ACPI MMIO devices, like TPM, has a fixed base GPA. Sould support
GPA resource allocating for MMIO devices. GPA region
0xF0000000~0xFE000000 is not used, can allocate GPA from it.

Tracked-On: #5913
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-05-18 15:49:30 +08:00
Sun Peng 7414a237b4 dm: mmio: Convert print output to acrn-dm logger
Unifies the logs to pr_* interfaces instead of printf for better log management.

Tracked-On: #5267
Signed-off-by: Sun Peng <peng.p.sun@intel.com>
Reviewed-by: Chi Mingqiang <mingqiang.chi@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2020-09-10 09:33:25 +08:00
Li Fei1 f13d5c25b6 dm: mmio_dev: add mmio device pass through support
We could add MMIO device pass through by two ways:
a) If the MMIO device only has MMIO regions and no ACPI Table touched, using
"--mmiodev_pt MMIO_regions",
b) If the MMIO device touches ACPI Table, using "--acpidev_pt HID"

Now only support TPM2 MSFT0101 MMIO device pass through through launch script
using "--acpidev_pt MSFT0101". When we want to pass through the TPM2 deivce,
we would not allow to emulate the vTPM2 at the same time. This is becuase
the ACRN-DM emulate the TPM2 as MSFT0101 too. Otherwise, the VM can't boot.

Besides, we could only support one TPM2 device PT and one MMIO device PT.
For TPM2 device PT, the MMIO resources are hard-coded. For the MMIO device PT,
we could pass through the MMIO resources on the cmdline.

ToDo:
1. We may use HID to discover the MMIO regions and ACPI Table instaed of
hard-coded.
2. To identify a MMIO device only by MMIO regions.
3. To allocate virtual MMIO regions in a reserved guest MMIO regions.

Tracked-On: #5053
Signed-off-by: Li Fei1 <fei1.li@intel.com>
2020-07-23 20:13:20 +08:00