Commit Graph

3272 Commits

Author SHA1 Message Date
Shiqing Gao 3d0992c7bd doc: update rules category in coding guidelines
This patch updates the rules category in coding guidelines.

Move some rules in 'Statements' part to 'Expressions' part and
'Functions' part, which is more reasonable.

No functional change is involved.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-04-08 16:03:48 -07:00
Sainath Grandhi 5b70c202e1 hv: Remove CONFIG_PARTITION_MODE used to compile out irq enable/disable
ACRN uses CONFIG_PARTITION_MODE  macro to compile out CPU_IRQ_ENABLE/DISABLE
APIs. With vector remapping enabled for pre-launched VMs, this is of no use.
And for VMs with LAPIC pass-thru, interrupts stay disabled in vmexit loop
with the help of is_lapic_pt() API.

Tracked-On: #2903
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-08 13:10:44 +08:00
Victor Sun 16de23d0d5 HV: move CONFIG_MAX_VM_NUM to vm configurations
Now the MAX supported VM number is defined explicitly for each scenario,
so move this config from Kconfig to VM configuration.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-08 13:08:55 +08:00
Victor Sun d3e4f69595 HV: use separated vm_config.c for each scenario
Previously we use unified vm_config.c for all scenarios and use MACROs
for each configuration items, then the initialization of vm_configs[]
becomes more complicated when definition of MACROs increase, so change
the coding style that all configurable items could be explicitly shown in
vm_configuration.c to make code more readable.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-08 13:08:55 +08:00
Geoffroy Van Cutsem d8cec9f9c4 doc: fix '@return' and '@retval' statements for vCPU ops
Add, update '@return' and '@retval' statements to the API descriptions related
to vCPU operations.

Tracked-On: #1844
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-04-08 11:07:16 +08:00
Yuan Liu 4a6bc369ad DM: virtio-gpio: implement GPIO operations via accessing PIO
GPIO set/get value can be operated by accessing PIO space and the PIO
register definition for GPIO is in gpio_dm.h, frontend driver or ACPI
control methods can operate GPIO based on it.

GPIO mediator also defines ACPI control methods to support GPIO
operations, GPIO consumers can invoke PIO_GPIO_SET_VALUE/PIO_GPIO_GET_VALUE
in their own DSDT to set/get one GPIO value via ACPI control method.

v2: 1) Fix code style.
    2) Use virtio configuration space callbacks to implement GPIO PIO operations
       that replace pci_gpio_read/pci_gpio_write with virtio_cfgread/virtio_cfgwrite.
    3) Return 0xFFFFFFFF as invalid result of PIO reading instead 0.

Tracked-On: #2512
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-08 10:51:49 +08:00
Geoffroy Van Cutsem a66aa65f05 doc: tweaks to the "User Guides" section (esp. "ACRN DM parameters")
Few tweaks to the "User Guides" and "ACRN Device Model parameters" docs:
- Enhance the help text for the '--rtvm' option description
- Correct the flag name to IO_COMPLETION_POLLING
- Use double-backticks instead of quotes in various places
- Explicitly list all docs in 'index.rst' to enforce special ordering

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-04-07 12:28:17 -07:00
David B. Kinder c09046abbf doc: add robots.txt
use a robots.txt file to prevent search engines from indexing old
content.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-04-04 15:51:27 -07:00
David B. Kinder fe470cfe23 doc: make doc version selector more obvious
Move the doc version selector menu higher on the left nav to make it
more visible (from its prior bottom of the nav menu)

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-04-04 14:47:23 -07:00
David B. Kinder 5531673f79 doc: fix broken link to kernel options
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-04-04 14:21:03 -07:00
David B. Kinder cfae3d4e95 doc: remove odd GVT-g link
Remove an incorrect link reference (and target) and fix some
misspellings.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-04-04 14:16:09 -07:00
David B. Kinder 4ec9edcf40 doc: fix memmap parameter description
Columns were switched for the description of the memmap parameter

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-04-04 13:53:43 -07:00
Geoffroy Van Cutsem 4cfd952413 doc: re-organize and consolidate ACRN kernel parameters documentation
A few changes to the documents that describe kernel command-line parameters
relevant to ACRN (SOS and UOS):
- Merge two documents into one (with sections)
- Move to the "User Guides" (from the "Developer Guides")
- Update order in the list to make it consistent across sections
- Add missing parameters to the overview list

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2019-04-04 13:38:30 -07:00
Shiqing Gao 1da23415a9 doc: add some rules related to function documentation
This patch adds some rules related to function documentation.

Tracked-On: #1844
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-04-04 11:47:07 -07:00
Conghui Chen e8dda1e914 DM USB: fix memory leak during reboot
1. free memory during pci_xhci_dev_destroy.
2. add libusb_free_device_list to free the list of devices previously
discovered using libusb_get_device_list().
3. fix possible memory corruption.

Tracked-On: #2892
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-04 18:35:02 +08:00
Sainath Grandhi f22347346e hv: Remove separate interrupt routine for pre-launched VMs
As vector re-mapping is enabled for pre-launched/partition mode VMs,
there is no more need for separate interrupt routine i.e.
partition_mode_dispatch_interrupt.

Tracked-On: #2879
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-04-04 17:51:36 +08:00
Sainath Grandhi 5b795a3312 hv: add the support of vector remapping for pre-launched VMs
For pre-launched VMs MSI/MSI-x configuration writes are not intercepted by ACRN.
It is pass-thru and interrupts land in ACRN and the guest vector is injected into
the VM's vLAPIC. With this patch, ACRN intercepts MSI/MSI-x config writes and take
the code path to remap interrupt vector/APIC ID as it does for SOS/UOS.

Tracked-On: #2879
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-04-04 17:51:36 +08:00
Kaige Fu c4ec7ac358 DM: Keep consistency between HV and DM about PM1A_CNT_ADDR
To keep consistency between HV and DM about PM1A_CNT_ADDR,
it is better to replace the PM1A_CNT related MACROs used in DM
with VIRTUAL_PM1A_CNT related MACROs in acrn_common.h.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2019-04-04 17:51:15 +08:00
Conghui Chen ede5987c11 dm: storage: add read-only feature for virtio-blk
Add VIRTIO_BLK_F_RO feature bit for virtio-blk.

Tracked-On: #2887
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-04-04 12:27:38 +08:00
Kaige Fu f4f9970623 doc: update documents for "--rtvm" parameter
This patch update documents for "--rtvm" parameter.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
2019-04-03 13:10:36 -07:00
Kaige Fu 469ce711c5 DM: Add new parameter --rtvm for soft/hard real-time guest
This patch add one new parameter --rtvm to indicate if the guest is a RTVM or not.
For RTVM, it may be not interference by SOS.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-04 00:27:55 +08:00
Kaige Fu 336ed72250 HV: Minor refinement about RTVM pm MACRO and comments
This patch mainly does the following:
  - Replace prefix RT_VM_ with VIRTUAL_.
  - Remove the check of "addr != RT_VM_PM1A_CNT_ADDR" as the handler is specific for this addr.
  - Add comments about the meaning of return value.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-04 00:27:55 +08:00
Kaige Fu 9c5e16987a HV: Remove the check pcpu active status when sending INIT
Intel SDM Vol3 23.8 says:
  The INIT signal is blocked whenever a logical processor is in VMX root operation.
  It is not blocked in VMX nonroot operation. Instead, INITs cause VM exits

So, there is no side-effect to send INIT signal regardless of pcpu active status.

Tracked-On: #2865
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-04-04 00:27:55 +08:00
Peter Fang f412d52546 dm: protect pthread_cond_wait() against spurious wakeups
Users of pthread_cond_wait() should take care of spurious wakeups and it
is usually used in conjunction with a predicate. Not doing so can result
in unintended behavior. For example:

virtio_net_tx_thread():
  entry -> pthread_cond_wait() -> spurious wakeup ->
  vq_clear_used_ring_flags() -> segfault (vq->used uninitialized)

tpm_crb_request_deliver():
  entry -> pthread_cond_wait() -> spurious wakeup ->
  swtpm_handle_request() called needlessly

virtio_rnd_get_entropy():
  entry -> pthread_cond_wait() -> spurious wakeup ->
  no avail ring processing ->
  virtio_rnd_notify() skips pthread_cond_signal() due to
  rnd->in_progress ->
  vq_endchains() called needlessly ->
  wait in pthread_cond_wait() indefinitely

Fix these uses of pthread_cond_wait() by using predicates.

The only use case without a clear predicate is the tx thread in
virtio-mei, because it works with two-dimensional linked lists.

v1 -> v2:
- fix bugs and comments
- reduce code redundancy

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang e9261121b3 dm: mei: code cleanup
- explicitly initialize the connections list
- use a do-while loop for vmei_proc_tx() since the first call must
  always succeed
- make sure active_clients is initialized before creating the tx thread

v1 -> v2:
- split the cleanup commit into two parts

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang bb54a2c7c6 dm: mei: use LIST_FOREACH() to traverse lists
Remove the uses of LIST_FIRST() and LIST_NEXT() plus an extra pointer.

Also, call LIST_INIT() in vmei_me_client_destroy_host_clients() before
releasing the mutex.

v1 -> v2:
- split the cleanup commit into two parts

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang 18aebc0196 dm: safely use pthread_cond_broadcast()
Use pthread_cond_broadcast() while holding the mutex to guarantee the
signaling of its condition variable.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang fa375a2aa1 dm: virtio: ensure interrupt delivery in virtio-blk
virtio-blk never sets used_all_avail when calling vq_endchains(), which
may become problematic if VIRTIO_F_NOTIFY_ON_EMPTY is enabled.

Provide vq_endchains() with that info to ensure the delivery of an
interrupt when the avail ring is drained in the case of
VIRTIO_F_NOTIFY_ON_EMPTY.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang d38afa6f48 dm: virtio: make sure VQ_ALLOC is set after initialization
Make sure VQ_ALLOC is visible only after vq is completely initialized.

This ensures vq_ring_ready() is reliable when it returns true.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Peter Fang 6be9f15aa6 dm: virtio: change return type to bool
Change return type to bool when returning int is not necessary.

Tracked-On: #2763
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2019-04-04 00:27:10 +08:00
Tianhua Sun 8b192b1583 hv: check vector count when set/reset msix info
'vector_cnt' is vector count of MSI/MSIX, and it come from 'table_count'
in the the pci_msix struct. 'CONFIG_MAX_MSIX_TABLE_NUM' is the maximum
number of MSI-X tables per device, so 'vector_cnt' must be less then
or equal to 'CONFIG_MAX_MSIX_TABLE_NUM'.

Tracked-On: #2881
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-03 16:33:17 +08:00
Huihuang Shi b316bf8a39 hv: fix "Else alternative missing in if."
All if . . else if constructs shall be
terminated with an else statement.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com
2019-04-03 09:20:55 +08:00
Victor Sun 7cff124b96 HV: removed unused pt_dev.c in board folder
The pt_dev.c in board folder is replaced by the one in scenarios folder,
so remove them.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
2019-04-02 21:42:07 +08:00
Qi Yadong 6d582f62d2 hv: trusty: minor change of coding style
Refine return value checking in functions.

Tracked-On: #2874
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 21:38:17 +08:00
Shiqing Gao a7e112813c hv: remove the unnecessary equality operation
This patch removes the unnecessary equality operation for
boolean variables.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-04-02 18:18:59 +08:00
Yan, Like ede1459e19 hv: fix the vm pointer check before use
After using get_vm_from_vmid(), vm pointer is always not NULL. But there are still many NULL pointer checks.
This commit replaced the NULL vm pointer check with a validation check which checks the vm status.
In addition, NULL check for pointer returned by get_sos_vm() and get_vm_config() is removed.

Tracked-On: #2520
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 16:29:51 +08:00
Yan, Like 275625af16 hv: renmae guest_no to vm_id in shell_to_sos_console()
This commit renmaes guest_no in shell_to_sos_console() to vm_id, which is commonly used in ACRN.

Tracked-On: #2520
Signed-off-by: Yan, Like <like.yan@intel.com>
2019-04-02 16:29:51 +08:00
Yan, Like ab62261a57 hv: add input vm_id check for hv shell commands
For hv shell commands with vm_id option, need to check it is in the valid range [0, CONFIG_MAX_VM].
This commit checks the input vm_id, if it's not in the valid range, an error message will be given,
and vm_id will be assgined to default 0U.

Tracked-On: #2520
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 16:29:51 +08:00
Victor Sun e35f27a525 HV: add clos initialization in vm_config
The CLOS is initialized to 0 for each scenarios. User could modify this
configuration in its vm_configurations.h;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 16:00:27 +08:00
Victor Sun 7580cddf9f HV: add scenario for logical partition
In this scenario, hypervisor will run two logical partition VMs.

Please note that the Kconfig of Hypervisor mode will be removed
gradually. In current Kconfig setting, the CONFIG_PARTITION_MODE
is still kept for now for back-compatibility.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 16:00:27 +08:00
Victor Sun 56c193851a HV: introduce scenario Kconfig for sharing mode
Previously the vm_configs[] is defined separately for sharing mode and
partition mode, but the concept of hypervisor mode will be removed. Instead
we will introduce scenario Kconfig for hypervisor to load different vm
configurations.

SDC(Software Defined Cockpit) is a typical scenario that ACRN supported
so we introduce this scenario for previously sharing mode and move its
configurations to scenarios/sdc folder. The configuration could be used
for all boards reference.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 16:00:27 +08:00
Victor Sun 564c9dcb79 HV: refine pt_dev.c for partition mode
Use MACROs in pt_dev.c to replace straight-forward BDF numbers. The
pt devices for each VM will be chosen from Board specific PCI devices
list which defined in pci_devices.h;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-02 16:00:27 +08:00
Tw 46e7fa8cf2 doc: minor changes according to one binary for SBL and UEFI
PLATFORM=xxx is no longer supported, use BOARD instead.

Tracked-On: #2708
Signed-off-by: Tw <wei.tan@intel.com>
2019-04-01 14:39:52 -07:00
David B. Kinder 1e614f5640 doc: add kernel parameters documentation
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-04-01 14:39:15 -07:00
Peter Fang 296c974dc0 OVMF release v0.8
- Remove QemuFwCfg/QemuFwCfgS3Lib
- Use ACRN E820 map to query system memory size
- Support 64-bit PCI host aperture via ACRN E820
- Remove debug code in release build
- Take out unnecessary OVMF drivers
- Revert "Enable MP support"
- Use CPUID 0x40000010 to determine tsc frequency

Tracked-On: #2868
Signed-off-by: Peter Fang <peter.fang@intel.com>
2019-04-01 12:39:42 +08:00
liuygzhuli e7f772444a Tools: acrnctl fix return value when it fails to execute the commands
Acrnctl commands return 0,even if when it fails to execute the commands.
 In this patch,fix this issue.It return none-zero when acrnctl commands
 failed in command executed.

 Tracked-On: #1262
 Signed-off-by:liuyonggang <yonggangx.liu@intel.com>
 Acked-by: Yan, Like <like.yan@intel.com>
2019-04-01 11:17:11 +08:00
liuygzhuli eea0ecd232 Tools: acrnctl fix return value when it fails to execute
the commands.

 acrnctl commands can manage multiple vms with a single
 command launched, which is not useful actually.
 To make the logic simple, this patch makes it to manage
 only a single vm by each command.

 Tracked-On: #1262
 Signed-off-by:liuyonggang <yonggangx.liu@intel.com>
 Acked-by: Yan, Like <like.yan@intel.com>
2019-04-01 11:17:11 +08:00
Jian Jun Chen cee45a80d9 hv: add default handlers for PIO/MMIO access
Add the default handlers for PIO and MMIO access which returns all
FFs on read and discards write. These default handlers are registered
when SOS VM or pre-launched VM is created.

v3 -> v4:
- use single layer if in hv_emulate_pio
- change the implementation of pio_default_read

v2 -> v3:
- use runtime vm type instead of CONFIG_PARTITION_MODE
- revise the pio/mmio emulation functions
- revise the pio/mmio default read functions according to MISRA C
- revise the commit message

v1 -> v2:
- add default handlers members in struct acrn_vm and add interfaces
  to register default handlers for PIO and MMIO.

Tracked-On: #2860
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-04-01 11:16:37 +08:00
yuhong.tao@intel.com 01b28c8e03 doc: Add tutorial about how to use CAT on UP2
Tracked-On: #2462
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-03-30 12:58:59 -04:00
Shiqing Gao 79582b996f doc: update software design guidelines
This patch adds the guidelines for 'Module Level
Configuration Design'.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-03-30 12:54:55 -04:00