Commit Graph

1503 Commits

Author SHA1 Message Date
Shiqing Gao 98aa74bd6b hv: treewide: fix 'No default case in switch statement'
MISRAC requires that a switch statement shall contain a default clause.

This patch add the default clause and some comments for the ones
violated the rule.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-10 16:49:31 +08:00
Alek Du 2a656812df misc: totally remove misc folder
misc now has a new home: https://github.com/intel/ioc-cbc-tools.

The "Execstop" patch will be synced to new git tree soon.

ioc-cbc-tools was just added to Clear Linux, and will be added to
software-defined-cockpit bundle after this patch merged.

Merging this patch may cause some IOC releated feature block until we
get a new Clear Linux release. This is the switch window ...

Signed-off-by: Alek Du <alek.du@intel.com>
2018-08-10 10:40:49 +08:00
Conghui Chen 49322ac002 dm: storage: support cache mode toggling
1. support "writeback" and "writethru" mode toggling for virtio-blk
conditionally. When starting DM with "writethru" parameter in
virtio-blk, guest OS could not toggle cache mode. When starting DM
with "writeback" parameter in virtio-blk, guest OS could toggle
cache mode.

    ------------------------------
    DM cmdline  | toggle support
    ------------+-----------------
    writeback   | yes
    writethru   | no
    ------------------------------

2. To toggle cache mode, run below command in guest OS:

    echo "write back" > /sys/devices/xxx/vdx/cache_type
OR
    echo "write through" > /sys/devices/xxx/vdx/cache_type

Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-08-10 10:33:21 +08:00
Conghui Chen f4fcf5d6eb dm: virtio: remove hv_caps from virtio_ops
currently, each virtio device has their own virtio_ops implementation.
Take virtio-blk for example:

static struct virtio_ops virtio_blk_ops = {
        "virtio_blk",
        1,
        sizeof(struct virtio_blk_config),
        virtio_blk_reset,
        virtio_blk_notify,
        virtio_blk_cfgread,
        virtio_blk_cfgwrite,
        NULL,
        NULL,
        VIRTIO_BLK_S_HOSTCAPS,
};

If start DM with two virtio-blk, this global variable will be
assigined to two virtio-blk instances. Changing hv_caps for one
instance will affect others. But different instances may need
different capabilities.

To support this requirement, we suggest to move hv_caps to
virtio_base structure, and each instance can return their own
capabilities.

Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-08-10 10:33:21 +08:00
Conghui Chen a2b299179d doc: update virtio-blk usage in HLD
Add parameters introduction for virtio-blk

Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-10 10:33:21 +08:00
Conghui Chen 2592ea8fa4 dm: storage: support writethru and writeback mode
In writethru mode, guest storage write are reported completed only
when the data has been written to physical storage.

In writeback mode, guest storage write are reported completed when
data is placed in SOS page cache. Needs to be flushed to the
physical storage.

USAGE:
    -s x,virtio-blk,<filepath>,writeback
    -s x,virtio-blk,<filepath>,writethru

The default mode is *writethru*

Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-08-10 10:33:21 +08:00
Sainath Grandhi 42cabf6965 hv: Handling IO exits in ACRN for partition mode
There is no SOS and device model in strict partition mode. ACRN emulates IO for
virtual devices. Any access to IO not backed by HV should return all FFs on read
and writes should be discarded.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-10 10:27:41 +08:00
Sainath Grandhi a8fcc0fa4b HV: Add vm_id entry to VM description in partitioning mode
ACRN boots multiple OS in partitioning mode. This patch adds code to assign
vm_id in the vm data structure to be same as the one assigned at compile time.
This makes the vm id deterministic for each VM booted from HV directly.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-10 10:26:38 +08:00
Sainath Grandhi d0e9f244ed hv: Interrupt handling in ACRN partition mode
ACRN in partition mode does not have vector and APIC ID remapping for
device interrupts. Only MSIs are supported. No IOAPIC and legacy interrupts
for the VMs in ACRN partition mode.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-10 10:26:00 +08:00
Sainath Grandhi 0c88f9b800 hv: Build mptable for OS in partition mode
This patch is an extension to the commit 6643adff8b.
It uses the mptable API to build mptable for each VM booted by ACRN in partition mode.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-10 10:22:51 +08:00
Sainath Grandhi e40b998d21 hv: Add EPT mapping for UOS in partitioning mode
Adding code to map memory for UOS in partitioning mode ACRN.
HPA starting above 4GB is used for UOS memory. Supports only contiguous memory
from host for UOS. Current implementation supports only 2 GB for UOS memory.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-10 10:22:06 +08:00
Yan, Like c492a14e53 hv: pirq: do not indicate priority when allocate vector
It's not necessary to specify priority for dynamic allocated vector, because
nested irq is not supported on HV, and irq of any priority would cause VM exit.

This commit makes the following changes:
 - remove the argument indicating priority in struct irq_request_info and
   following functions:
    ptdev_activate_entry()
    find_available_vector()
    irq_desc_alloc_vector()
    normal_register_handler()
 - change the macro of vector ranges:
    VECTOR_DYNAMIC_START/END for dynamically allocable vectors;
    VECTOR_FIXED_START/END for fixed allocated vectors, such as vector for
    timer etc.

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-10 10:20:31 +08:00
Mingqiang Chi 229bf32eb5 hv:Refine destroy_secure_world API
-- add clear trusty memory flag
  In some cases such as UOS power off or UOS full reset,
  need to clear trusty memory,no need to clear memory such as
  UOS S3 or UOS system reset,then add a flag to distinguish it
  when destroy secure world.
-- Restore trusty memory to guest normal world.
-- Moved free trusty EPT inside destroy_secure_world
  In some cases such as UOS S3 or UOS system reset,
  only need to free trusty EPT, this patch move free
  trusty EPT inside destroy_secure_world.
  Because PD/PT are shared in both secure world's EPT
  and normal world's EPT,before freeing trusty EPT,
  it will memset all PDPTEs except trusty memory,
  then call 'free_ept_mem', it can only free trusty EPT,
  and does't affect shared normal world EPT.

v2-->v3:
    -- Used new mmu api ept_mr_add when restore trusty memory
       to SOS and normal world
    -- Dropped this patch "Removed reverted page tables for trusty memory"
       because map_mem will be removed in future
       It will have a patch, need to update this api(ept_mr_add),
       it will not create inverted page tables for trusty memory.

v1-->v2:
   -- free trusty ept
       still use free_ept_mem, not add a new api,but need to
       memset pdptes except trusty memory
   -- Removed reverted page tables for trusty memory.

Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-10 10:17:09 +08:00
Shiqing Gao 40196d16af hv: treewide: fix 'inline function should be declared static'
MISRAC does not allow the use of an inline function with external
linkage.

What this patch does:
- Add the static keyword for the function that is only used in the
  definition file.
- Remove the inline keyword for the function that is used in multiple
  files.

v1 -> v2:
 * Move some functions to headers as static inline function if it is
    possible

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2018-08-10 10:16:04 +08:00
Shiqing Gao cdd19dc51b hv: treewide: fix 'Variable should be declared static'
Declare a variable with the static qualifier if it is of file scope and
not used in another file.

v1 -> v2:
 * remove the unnecessary change to the following variables, which is
    due to the report issue

   struct multiboot_info *mbi = (struct multiboot_info *)
                        (HPA2HVA((uint64_t)boot_regs[1]));
   struct multiboot_mmap *mmap =
                                (struct multiboot_mmap *)
                                HPA2HVA((uint64_t)mbi->mi_mmap_addr);

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2018-08-10 10:15:36 +08:00
dongshen 183ca5d175 HV: Adding hostbridge vdev device support for partition hypervisor
V4:
 - Moved error checking to vdev_hostbridge_cfgwrite/vdev_hostbridge_cfgread

V3:
 - Unified ops calling and implemented deinit/cfgwrite/cfgread ops,
      previously only init op is implemented

Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-08-10 10:09:00 +08:00
dongshen 181de19cba HV: Adding passthru vdev device support for partition hypervisor
V4:
 - Renamed members for struct pcibar and changed code accordingly

V3:
 - Do not use ASSERT
 - Use EPT_XX defines when claling ept_mr_add
 - Report 64-bit MMIO physical bar to UOS as 32-bit virtual bar
   (assume bar size is always less than 4GB), which removed quite some of
   64-bit bar handling code

Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-08-10 10:09:00 +08:00
dongshen 5f3ea06feb HV: Implementing PCI CFG vm-exit handler for partition hypervisor
V4:
 - If pci device is not found in the PCI mapping table, just return without
   throwing any error message
 - Added NULL pointer checking when calling cfgread/cfgwrite ops
 - Moved error checking code to cfgread/cfgwrite ops

V3:
 - Do not use ASSERT
 - Call the cfg read/write ops defined in the vm description

V2:
 - Fixed MISRA violations

Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-08-10 10:09:00 +08:00
dongshen 86180bd4ce HV: Calling into VPCI init/unit functions for partition hypervisor
V4:
 - Clear address cache info after a full cf8/cfc access
 - Add NULL pointer checking when calling init/deinit ops

V3:
 - Do not use ASSERT
 - Loop through the vdev list defined in vm_desctiption table to call the vdev init/unit functions
 - Make the cached vbdf info struct per vm instead of per pcpu

V2:
 - Fixed MISRA violations

Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-08-10 10:09:00 +08:00
dongshen 65bd038650 HV: Compiling in VCPI code for partition hypervisor
V3:
- Compiling in VCPI code for partition hypervisor

Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-08-10 10:09:00 +08:00
dongshen f60fcb6b16 HV: Defining the per-vm static vpci table for partition hypervisor
V4:
- Renamed members for struct pcibar
- License header fix
- Added vpci_vdev_array to struct vm_description

V3:
 - Defined the static centralized vpci table to reduce code size,
   previously many of the settings are obtained/generated dynamically

Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-08-10 10:09:00 +08:00
Binbin Wu 2b22e88b51 hv: init: rm the code of creating guest init page table
If SOS start from 64bit mode, it will use the page table
created by bootloader or BIOS. HV doesn't need to create
page table for it.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 16:43:58 +08:00
Binbin Wu 33e1149b29 hv: init: unify init logic for vm0 bsp
In current code, VM0 BSP start mode is hardcoded, in this patch VM0 BSP
start mode is decided by the boot context prepared by bootloader/BIOS.

In current code, VM0 BSP VMCS is override only on UEFI platform.
In this patch, VM0 BSP VMCS is override on both SBL & UEFI platforms.

Also restructure the code of guest init code.
In this patch, a vcpu run_context is initilaized first according to vcpu mode.
Then write the value to vmcs according to run_context value.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 16:43:58 +08:00
Binbin Wu 4acce9338a hv: move save_segment/load_segment to a header file
save_segment/load_segment is common code and can be used outside of trusty,
move to a header file.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 16:43:58 +08:00
Binbin Wu 43db87cfed hv: rename acrn_efi.h to vm0_boot.h
The structures defined in acrn_efi.h is x86 related, move it
to acrh/x86/guest/.
Also, the headfile will be used on both SBL & UEFI platforms,
rename it to vm0_boot.h

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 16:43:58 +08:00
Binbin Wu adddf512a6 hv: move define of struct cpu_gp_regs to a separate headfile
EFI stub code need to reference to the struct cpu_gp_regs, which
is currently defined in vcpu.h, however include vcpu.h in EFI stub code
will include other header files not requried by EFI stub code.
After moving the define of struct cpu_gp_regs to a separate
headfile, the file can be included in EFI stub code without other header
files.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 16:43:58 +08:00
Binbin Wu 5a5b2a1ead hv: init: save boot context from bootloader/bios
Add code to save boot context, which is prepare by the bootloader or
BIOS, the context can be used to init sos vmcs, such as GDT, IDT,
segment selectors, control registers, ia32_efer. In this way, HV can
leverage the data structures built by bootloader or BIOS, without
creating them in HV.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-08-09 16:43:58 +08:00
Edwin Zhai ac39b90515 DM: update GSI sharing info
With latest FW, ethernet/wifi BDF changes from 3:0.0/4:0.0 to
2:0.0/3:0.0.

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 15:42:51 +08:00
Qi Yadong 2fc3bdec40 HV: trusty: new hypercall to save/restore context of secure world
New field in VM's structure:
    sworld_snapshot: save cpu_context of secure world.

New hypercall: HC_SAVE_RESTORE_SWORLD_CTX
    In UOS S3 suspend path: trusty kernel driver will call this hypercall
    to require Hypervisor save context of secure world.
    In UOS S3 resume path: virtual firmware will call this hypercall to
    require Hypervisor restore context of secure world.

New bit in secure_world_control.flag:
    ctx_saved: indicate whether cpu_context of secure world is saved.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 15:09:15 +08:00
Qi Yadong 3225b16e5f HV: trusty: log printing cleanup
Replace some pr_err() with dev_dbg().

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 15:09:15 +08:00
Qi Yadong 9ba14dac31 HV: trusty: remove unused HC ID
The security information will not pass to HV through Hypercall,
so remove the unused HC_GET_SEC_INFO.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 15:09:15 +08:00
Qi Yadong b5b769f45a HV: trusty: refine secure_world_control
Define Bitmap flag to indicate secure world's state:
    supported: 0(not supported), 1(supported)
    active:    0(inactive), 1(active)

Refine secure_world_memory:
    base_gpa_in_sos: base_gpa from SOS's view
    base_gpa_in_uos: base_gpa from UOS's view, this is the original base_gpa
                     allocated by bootloader.
    Recording above GPA is for usage of trusty EPT destroy and re-create.
    There is an assumption: the secure world's memory address is contiguous
    in both SOS and physical side.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-09 15:09:15 +08:00
Sainath Grandhi ff96453993 hv: Boot multiple OS for Partitioning mode ACRN
ACRN in partitioning mode boots multiple OS. Adding code to parse
VM description structure and a reference description structure for
booting 2 OSes.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-09 15:01:57 +08:00
Liu, Xinwu 5e32c0227f tools:acrn-crashlog: Enhance some functions
The changes include:

1. modify the outparam only in successful cases.
2. return -1 instead of  a errno-style value if error happens.
3. check return value of strrchr.

Tracked-On: #971
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-08-09 14:48:36 +08:00
Yin Fengwei 10f0bb012a hv: remove push/pop instruction emulation.
It's not reasonable to use push/pop against mmio. So we remove
the push/pop emulation.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-09 14:46:13 +08:00
Yin Fengwei fa9fec50e9 hv: inject invalid opcode if decode instruction fails
We inject invalid opcode if instruction decode fails.

We don't support many instruction. If new type guest hit
the invalid opcode and it's necessary to emulate that
instruction, we could add new instruction then.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-09 14:46:13 +08:00
Yin Fengwei 1a00d6c943 hv: add more exception injection API
TO inject the
  - Invalid Opcode exception
  - Stack Fault exception
  - Alignment Check exception
to guest.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-09 14:46:13 +08:00
Yin Fengwei 96e99e3a72 hv: use more reliable method to get guest DPL.
The DPL from SS access right field is always correct according
to SDM. We use it instead of using CS selector.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-08-09 14:46:13 +08:00
Yin Fengwei 63fe48c27f hv: get correct fault address for copy_to/from_gva
When doing copy_to/from_gva, it's possible the guest no page
happens on none-first page. In this case, we need get correct
fault address from gva2gpa.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-08-09 14:46:13 +08:00
Junjie Mao 55105dbdeb DM: notify VHM request complete after pausing the VM
It is necessary to notify the VHM and hypervisor on the completion of a VHM
request even when the UOS is in suspend or system reset mode because the VHM and
hypervisor rely on the notification to reset their own states on the
request.

Currently the VHM request state is checked against REQ_STATE_PROCESSING instead
of REQ_STATE_COMPLETE when handling system reset or suspend/resume, leading to a
completed request unnotified, and causing the HV to complain on an occupied VHM
request when it raises a new one.

This patch fixes this issue by properly notifying completed requests to the VHM
& hypervisor. Some concerns are raised during a discussion on the potential
races which does not hurt for now but may in the future. These considerations
and potential solutions are documented as comments for future reference.

Tracked-On: #895
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-08-09 12:52:14 +08:00
David B. Kinder 4753da4374 doc: add interrupt high-level design doc
Transcode, review, and publish interrupt high-level design document.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-08 20:23:12 -07:00
Wei Liu 11c209e862 DM: add tag info while no repo in release
there is no git repo, which download from github release,
however, acrn-dm -v will get tag info from this repo, in
such case, the tag info was null.
this patch will fix nul tag, which get it from CL mock build.

Tracked-On: #676
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-08-09 09:47:08 +08:00
Tan Yew Wayne 8af90e0154 misc: Remove unnecessary ExecStop in systemd services
From systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStop=
> If this option is not specified, the process is terminated by sending the signal specified in KillSignal= when service stop is requested.

https://www.freedesktop.org/software/systemd/man/systemd.kill.html#KillSignal=
> Defaults to SIGTERM.

Signed-off-by: Tan Yew Wayne <yew.wayne.tan@intel.com>
2018-08-09 08:58:12 +08:00
Shiqing Gao 4106fadeb3 hv: treewide: fix 'Switch empty default has no comment'
This patch add some comments after the default and before the break
in the switch statement based on MISRA-C requirement.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2018-08-08 16:01:57 +08:00
Minggui Cao af7943c5e6 DM: check more in guest service & launch script
some exceptions can happen if westnon or network name service
not started before launch uos guest, like gvt and network exceptions,
which can cause SOS reboot. so add the dependency.

add data partiton check in launch script, for it can be called in every
clearlinux platform.

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-08-08 16:00:56 +08:00
Sainath Grandhi 04b4c9110c hv: Adding a wrapper on top of prepare_vm0
Added prepare_vm function as a wrapper function on top of prepare_vm0.
This makes adding support for partition mode ACRN to boot multiple
VMs from HV cleaner.

Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2018-08-08 15:53:46 +08:00
Junjie Mao 638d7141d2 DM: adapt to the new VHM request state transitions
This is the counterpart in DM to the VHM request state update in the
hypervisor. Major changes include:

    * Remove accesses to the obsolete 'valid' member.
    * Access the 'processed' member using atomic operations.
    * Sync the documentation on vhm_request.

In addition, the new state transition also requires a VHM request to be always
handled properly, as there is no 'FAILED' state any more. Instead of crashing
the device model (and thus the UOS as well), the device model should return all
1s or ignore the request when it is to load from or store to an invalid address,
respectively.

Note: there is an issue in vm_system_reset() and vm_suspend_resume() where
completed VHM requests are not properly notified, causing the hypervisor to
complain as it sees uncompleted requests while trying to create a new one. This
issue will be resolved in a separate patch.

v1 -> v2:

    * Use macro-defined constants for the default values for invalid PIO/MMIO
      reads.
    * Change the return type of vmexit_handler_t in DM to void as the return
      values are no longer necessary.
    * Remove VM_EXITCODE that are no longer used.

Tracked-On: #875
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-08-08 15:53:07 +08:00
Junjie Mao ea137589e6 DM: add wrappers to gcc built-in atomic operations
This patch introduces wrappers to the built-in atomic operations provided by
gcc.

There are two sets of built-in atomic functions available. Before gcc 4.7.0 only
the __sync built-in functions are available, while since 4.7.0 a new set of
built-in functions with the __atomic prefix is introduced as a
replacement. Since the __sync functions will eventually be deprecated, the
__atomic ones are preferred whenever available.

The interfaces provided are listed below, mostly following the naming of the
underlying built-in functions which explain themselves.

    atomic_load
    atomic_store
    atomic_xchg
    atomic_cmpxchg

    atomic_add_fetch
    atomic_sub_fetch
    atomic_and_fetch
    atomic_xor_fetch
    atomic_or_fetch
    atomic_nand_fetch

    atomic_fetch_add
    atomic_fetch_sub
    atomic_fetch_and
    atomic_fetch_xor
    atomic_fetch_or
    atomic_fetch_nand

    atomic_test_and_set
    atomic_clear
    atomic_thread_fence
    atomic_signal_fence

Tracked-On: #875
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-08-08 15:53:07 +08:00
Shiqing Gao c0544c9d36 hv: treewide: fix 'Potential side effect problem in expression'
MISRA-C requirement:
The value of an expression shall be the same under any order of
evaluation.
The order in which side effects take place is unspecified and may lead
to unexpected results.

This patch add a temporary variable for temporary storage to avoid the
side effects of evaluation order.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-08 10:50:06 +08:00
Jason Chen CJ b1612e3072 add cpu_do_idle to handle idle
add wrap function cpu_do_idle in default_idle to handle arch cpu specific
idle operation.

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-08-08 10:00:51 +08:00