Commit Graph

3240 Commits

Author SHA1 Message Date
Viktor Sjölind 5f51e4a762 pci.c: assert MSIX table count <= config max
Assert that PCI devices discovered while booting the hypervisor do not
have more table entries than allowed by the compile-time configuration
(CONFIG_MAX_MSIX_TABLE_NUM).

The case were `msix.table_count` > `CONFIG_MAX_MSIX_TABLE_NUM` is fatal
since the init function in the handler for MSI-X (vmsix_init) only looks
at `table_count` when populating the table. Since
`CONFIG_MAX_MSIX_TABLE_NUM` is the max size of the table array entry in
the pci_msix struct. This will cause the msix handler to write outside of
the table array.

Tracked-On: #2624
Signed-off-by: Viktor Sjölind <vsjolind@luxoft.com>
2019-03-08 23:04:12 +08:00
Sainath Grandhi 137892fdd5 hv: Remove multiple definitions for dmar translation structures
Except for few translation structures in x86 IOMMU, all translation
structures are 128-bit. All the translation structures used by ACRN
are 128 bit. So removed multiple definitions and defined a struct
that accomodates 128 bit entries.

Tracked-On: #2668
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-03-08 15:23:20 +08:00
Shiqing Gao 18b619da4d doc: add the doc for 'Error Detection and Handling'
This patch adds the doc for 'Error Detection and Handling'.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-03-07 22:12:10 -08:00
Shiqing Gao 72fbc7e79f doc: add some comments for coding guidelines
This patch adds some comments for coding guidelines.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-03-07 22:05:05 -08:00
Tonny Tzeng e779982c6f doc: use the new board name for UP2 in create-up2-images.sh script
The board name for building images for UP2 has been changed from 'up2' to 'apl-up2' by the commit #f9b5e21.

Signed-off-by: Tonny Tzeng <tonny.tzeng@intel.com>
2019-03-07 22:04:04 -08:00
Zide Chen bf1aa5c134 hv: destroy IOMMU domain after vpci_cleanup()
In partition mode, unassign_iommu_device() is called from vpci_cleanup(),
so when shutdown_vm() is called, unassign_iommu_device() could fail because
of "domain id mismatch" and DMAR is not cleared.

Also move destroy_ept() after the call to destroy_iommu_domain().

Tracked-On: #2700
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-08 13:20:11 +08:00
yuhong.tao@intel.com c0400b99fb HV: Fix modularization vm config code lost CAT code
Previous change 'HV: modularization vm config code', commit id
1bb15c64a6, lost CAT code when move
sanitize_vm_config() from vm.c to vm_config.c

Tracked-On: #2291
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-03-08 12:38:48 +08:00
Victor Sun 649406b049 HV: refine location of platform_acpi_info header
platform_acpi_info.h should be BOARD specific so move the header file
to configs/$(CONFIG_BOARD)/ folder.

So the target acpi info file detect process is:

Compiler search for $(CONFIG_BOARD)_acpi_info.h under
hypervisor/arch/x86/$(CONFIG_BOARD)/ first (the file is supposed to be
generated by offline tool so it is not included in original source), if
found, then the file is the target acpi info file. If not and at the
same time the ENFORCE_VALIDATED_ACPI_INFO Kconfig was set, the compiler
will stop and hint user to add target acpi info file by offline tool.
If ENFORCE_VALIDATED_ACPI_INFO was unset, then compiler will continue to
search for platform_acpi_info.h as target acpi info file under
hypervisor/arch/x86/$(CONFIG_BOARD) folder (with this file we could bypass
ENFORCE_VALIDATED_ACPI_INFO check and benifit for development). If this
file is not exist, then hypervisor/arch/x86/configs/platform_acpi_info.h
will be included as final target acpi info.

The process should work for UEFI path also, with a valid platform acpi
info file, S3/S5 should work on UEFI platform.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-08 10:34:14 +08:00
David B. Kinder ff9ef2a19d doc: fix broken external links
Found some broken links to external sites in the documentation.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-03-07 15:52:39 -08:00
Shiqing Gao 85b3ed3e8d doc: update the format in coding style part
This patch updates the format in coding style part.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-03-07 15:51:19 -08:00
Yuan Liu f6a989b7be dm: use power button acpi device to find its input event
check the power button acpi driver firstly, then find input event
corresponding to the power button.

Tracked-On: #2695
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-07 20:23:48 +08:00
Mingqiang Chi 55f52978db hv:move several tsc APIs to timer.c
-- change 'tsc_khz' to static
-- move these APIs from rtl.h to timer.c
   us_to_ticks()
   ticks_to_us()
   ticks_to_ms()
   rdtsc()

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-07 20:23:22 +08:00
Yonghua Huang 36f6a412b7 hv:validate ID and state of vCPU for related APIs
to validate the ID and state of vCPU in below functions:
  - hcall_set_vcpu_regs()
  - hcall_notify_ioreq_finish()
  - shell_vcpu_dumpreq()

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-07 20:22:42 +08:00
Minggui Cao 9922c3a7f5 HV: correct COM_IRQ default config type
change the config type of COM_IRQ from "hex" to "int"; make
it consistent with its default value.

Tracked-On: #2689
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-03-07 17:52:56 +08:00
Yan, Like 741501c2e3 hv: refine vlapic_calc_dest()
This commit extracts the common logic of vlapic_calc_dest() and vlapic_calc_dest_lapic_pt()
to static inline functions, in order to make vlapic_calc_dest() clean and easy to read.

Tracked-On: #1842
Signed-off-by: Yan, Like <like.yan@intel.com>
2019-03-06 11:43:51 +08:00
Binbin Wu f572d1ecdd [RevertMe] dm: pci: restore workaround when alloc pci mem64 bar
There was a workaround in DM that allocates PCI 64bit mem bar in 32bit mem space
if the bar size is within 32MB.

After the workaround being removed, there is an issue to enter fastboot
mode for inappropriate handling of 64bit mem bar in guest driver.
The patch bring the workaround back, and skip the workaround when the guest
is booted by OVMF.

Revert the patch after the guest fixs the issue of handling 64bit mem bar in
fastboot mode.

Tracked-On: #2677
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-05 15:14:24 +08:00
Li, Fei1 ca3d4fca55 hv: vlapic: move LVT IRQ vector check to vlapic_fire_lvt
We could simple the vector check for LVT IRQ by move this check to
vlapic_fire_lvt when the IRQ is fixed mode.

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-03-05 13:33:36 +08:00
Li, Fei1 473d31c073 hv: vlapic: add vector check for x2apic SELF IPI
Set when the local APIC detects an illegal vector (one in the range 0 to 15)
in the message that it is sending. This occurs as the result of a write to the
ICR (in both xAPIC and x2APIC modes) or to SELF IPI register (x2APIC mode only)
with an illegal vector.

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-05 13:33:36 +08:00
Li, Fei1 e5d3a49894 hv: vlapic: call vlapic_accept_intr directly in vlapic_set_error
LVT ERROR is an edge and fixed mode interrupt. We could call vlapic_accept_intr
to fire it directly. Otherwise, if LVT ERR vector is invalid, an invalid
interrupt will be accepted in IRR.

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-03-05 13:33:36 +08:00
Zide Chen 2b35c07857 hv: do EPT mapping only for physical memory backed GPA on pre-launched VMs
Currently for pre-launched VMs, HV intends to do EPT mapping for all GPA
space, which implies that it wastes HPA to back PCI hole and other vE820
entries that are not backed by physical memory.

This patch solves this issue and fixes ve820 entries whose length is not
aligned to 4K, and changes the lowmem entry's start GPA from 1MB to 2MB.

Tracked-On: #2587
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-03-05 10:05:24 +08:00
Shiqing Gao da14c96135 hv: simplify `get_primary_vcpu` and `vcpu_from_vid`
This patch simplifies `get_primary_vcpu` and `vcpu_from_vid`.
The target_vcpu could be get from the index directly.

Tracked-On: #1842
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-04 13:45:02 +08:00
Li, Fei1 3d0d8609cc hv: vlapic: correct wrong use of vector
Correct wrong use of vector where lvt_index should be used.

Tracked-On: #1842
Signed-off-by: Min He <min.he@intel.com>
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-03-04 13:44:15 +08:00
Xinyun Liu 0943a836bd [hv] set ECX.bit31 to indicate the presence of a hypervisor
ECS.bit31 is not used and always return 0 in SDM Vol.2A 3-195. It's a
standard way to indicate whether there is a hypervisor.

Tracked-On: #2490
Ref: https://lwn.net/Articles/301888/
Signed-off-by: Xinyun Liu <xinyun.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-03-04 13:43:48 +08:00
Sainath Grandhi f6758fd621 hv: fix a redundant check in general_sw_loader
vcpu returned by get_primary_vcpu API is BSP vcpu of the VM. So
checking is_vcpu_bsp on vcpu is redundant.

Tracked-On: #2668
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2019-03-04 10:08:20 +08:00
Sainath Grandhi b49df10a23 hv: Remove redundant get_dmar_info API calls
get_dmar_info API is called from multiple functions in vtd.c. This patch
calls get_dmar_info once during init and uses the cached info during
runtime.

Tracked-On: #2657
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-02 07:10:25 +08:00
Mingqiang Chi 308d4e8c4e hv:move forward the initialization for iommu & ptdev
move 'init_iommu()' & 'ptdev_init()' before starting
all secondary cores to avoid access uninitialized resource
in partition mode.

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-02 07:10:12 +08:00
Shiqing Gao bc107105f8 doc: fix the typo related to tab
This patch fixes the typo related to tab.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-03-01 08:36:00 -08:00
Long Liu 8a324060c1 ACRN: dm: Fix luanch UOS script "-d" parameter fail issue
Fix launch UOS script "-d" parameter fail issue

Tracked-On: #2659
Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-03-01 20:23:46 +08:00
Peter Fang 061189981d OVMF release v0.7
- Change system timer from 8254 to HPET
- Fix UEFI console UI issue
- Enable MP support
- Install ACRN DM's ACPI tables
- Remove Bhyve ACPI tables
- fix backspace issue in UEFI shell
- clear CD bit in SEC
- Revert "workaround: disable CR0.CD"
- workaround: disable CR0.CD
- boots Clear Linux (1 vcpu)

Tracked-On: #2662
Signed-off-by: Peter Fang <peter.fang@intel.com>
2019-03-01 20:23:22 +08:00
dongshen 6794660e4f HV: use the common functions defined in vdev.c to reduce duplicate code
Both sharing mode and parittioin mode code can use the pci_find_vdev_by_pbdf
and pci_find_vdev_by_vbdf functions defined in vdev.c instead,
and remove the corresponding functions in other files.

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 14:12:14 +08:00
dongshen be3fbaa461 HV: add generic vdev functions to vdev.c
Add vdev functions so they can be reused by both partition mode
and sharing mode code:
pci_find_vdev_by_vbdf: search for vdev by virtual bdf
pci_find_vdev_by_pbdf: search for vdev by physical bdf

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 14:12:14 +08:00
dongshen 731b0444b1 HV: rename core.c to vdev.c
core.c contains functions all related to pci vdev management, so it makes sense
to give it a more meaningful file name.

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 14:12:14 +08:00
dongshen 819bcec693 HV: remove sharing_mode_vdev_array from sharing_mode.c
Sharing mode has its own static global variables to store
number of vdevs and vdev list, we already have the per vpci pci_vdev[]
in struct acrn_vpci, so use the vpci_vdev in acrn_vpci instead to unify
the vdev list management for both sharing mode and partition mode.

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 14:12:14 +08:00
dongshen 00f9b85072 HV: move pci_vdevs[] array from vm.h to vpci.h
pci_vdevs is vpci stuff so it would be better to make it managed by vpci rather than by vm.h,
both sharing mode and partition mode can use pci_vdevs[] to maintain its own
per vm vdev list.

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 14:12:14 +08:00
David B. Kinder 8c3cfe62aa doc: add VBSK overhead analysis doc
Add a new developer guide describing VBSK overhead analysis.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-02-28 20:25:19 -08:00
Shiqing Gao 30159d5b28 doc: add some rules related to coding style
This patch adds some rules related to coding style.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-02-28 20:01:01 -08:00
Victor Sun ff65a10391 HV: vm_configs array refinement
- merge sharing_config.c and partition_config.c to vm_config.c;

- make vm_configs[] static;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 10:32:49 +08:00
Victor Sun 0d90515bf6 HV: refine is_lapic_pt
- Do not refer vm_configs[] directly in vm module;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 10:32:49 +08:00
Victor Sun 1bb15c64a6 HV: modularization vm config code
- move sanitize_vm_config() from vm.c to vm_config.c;

- move get_vm_config() from vm.h to vm_config.h;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-03-01 10:32:49 +08:00
Yuan Liu 35dfadc98e dm: check SCI_EN bit of pm1_control before trigger SCI
Followed ACPI spec 4.8.2.5, if SCI_EN is set, the interrupt will be
routed to SCI interrupt logic. If SCI_EN is not set, the interrupt
will be routed to SMI interrupt logic.

ACRN does not support SMI for now, so check SCI_EN before trigger
SCI.

Tracked-On: #2560
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-01 08:09:42 +08:00
Yuan Liu 566e8824da dm: power button emulation by acrnctl command.
when UOS is running, "acrnctl suspend vm" and "acrnctl stop vm" commands are
able to trigger a SCI interrupt, then UOS enters sleep or shutdown according
to the default behavior of the power button. The default behavior is based on
UOS power button setting.

Tracked-On: #2560
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-01 08:09:42 +08:00
David B. Kinder 32a7b4f179 doc: add IOC virtualization HLD
Convert and edit IOC virtualization doc to add to ACRN documentation.
Add a note that IOC virtualization is not supported on the NUC or UP2
platforms.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-02-28 11:55:32 -08:00
Jian Jun Chen c69dab0a11 hv: add support of EPT mapping of high MMIO
Enlarge hypervisor BSS section to support EPT mapping of additional
1G address space. This is used to support 64bit PCI bar whose address
is strictly above 4G.

Tracked-On: #2577
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-02-28 18:33:11 +08:00
Jian Jun Chen 29b1ebcd43 dm: add support of high MMIO mapping
1G PCI hole is added just after 4G address which is used as the
PCI high MMIO address space. Guest high memory is mapped from 5G
address for both EPT and device model user space address. Guest
e820 table and API vm_map_gpa are updated accordingly.

Tracked-On: #2577
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 18:33:11 +08:00
Liu Shuo A 32925c10bd dm: allocate 64bit MMIO above 4G strictly to pass OVMF check
Remove the >32MB limitation for 64bits mmio hole allocation, ACRN
hasn't met such buggy devices for this limitation. Besides, OVMF
has one bug which requires 64bits BAR must allocate from 4G+ address,
otherwise trigger assert. This patch can workaround it.

Tracked-On: #2577
Signed-off-by: Liu Shuo A <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 18:33:11 +08:00
Shuo Liu aed75145c1 dm: Limit 64 bits PCI BAR region address space
Limit 64 bits PCI BAR space from 0x100000000UL ~ 0x140000000UL,
as HV now only support 0x400000000UL+0x80000000 as top of guest memory
address. EPT table size is static allocated.

Tracked-On: #2577
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 18:33:11 +08:00
Yuan Liu 7628e790e7 DM: virtio-gpio: use virtio_base as the first member of virtio_gpio
For virtio-based device, it needs to use virtio_base as the first member
otherwise, virtio_linkup will fail.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-02-28 17:19:36 +08:00
Minggui Cao a89c41dd4c HV: cleanup header files under hypervisor/common
it removes hypervisor.h and just includes needed header files.

Tracked-On: #1842
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-02-28 14:59:22 +08:00
Minggui Cao 3cb5542b0a HV: cleanup header files under hypervisor/dm
it removes hypervisor.h and just includes needed header files.

Tracked-On: #1842
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-02-28 14:59:22 +08:00
Liu, Xinwu e299553896 tools: acrn-crashlog: new file to count all events happened in system
Since "history_event" file records limited events (5000 lines by default),
a new file named "all events" to count all kind of events.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2019-02-28 13:18:57 +08:00