Commit Graph

331 Commits

Author SHA1 Message Date
Huang, Yang 7003e50e4e DM: Refactor RPMB files
Move rpmb_sim.c and rpmb_backend.c to hw/platform/rpmb/

Signed-off-by: Huang Yang <yang.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-30 13:51:03 +08:00
Huang, Yang 113ece2854 DM: Enable full 4MB access
A simulated rpmbfile requires to enable 4MB access by writing
the last byte.
Otherwise, the read operation should be failed if no write
was operated on the address greater than the read address.
Writing the last byte during file creating ensures the whole
4MB address is readable.

Signed-off-by: Huang Yang <yang.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-30 13:51:03 +08:00
Huang, Yang dc566ab3ac DM: refine vRPMB logs
Remove unused logs and correct spelling

Signed-off-by: Huang Yang <yang.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-30 13:51:03 +08:00
Huang, Yang c7d1460dfb DM: Fix potential overflow and return value issues
Fix by a fixed string length and correcting return value

Signed-off-by: Huang Yang <yang.huang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-30 13:51:03 +08:00
Fei Jiang 5b1c536eee DM sample: update sos/uos boot arg to let Android UOS see two displays
Android HWC has problem when only see one display, then this is
workaround patch to make Android HDMI2 display normal.

V2: only change AaaG UOS kernel boot arg

Signed-off-by: Fei Jiang <fei.jiang@intel.com>
2018-05-29 16:53:22 +08:00
Junjie Mao ef3cb5ba1c treewide: remove unnecessary unnamed structs/unions
According to the syntax defined in C99, each struct/union field must have an
identifier. This patch removes unnamed struct/union fields that can be easily
expressed in a C99-compatible way.

Here is a summary of structs/unions removed.

struct vhm_request:

    union {
        uint32_t type;                  uint32_t type;
        int32_t reserved0[16];    =>    int32_t reserved0[15];
    };

struct vhm_request_buffer:

    struct vhm_request_buffer {
        union {                         union vhm_request_buffer {
            struct vhm_request ...; =>        struct vhm_request ...;
            int8_t reserved[4096];            int8_t reserved[4096];
        }                               }
    }

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-29 14:12:15 +08:00
Edwin Zhai 4b4e1e1c59 DM: Add option of no check against ptdev reset
With '--ptdev_no_reset', DM doen not abort but warn when assign PCIe
dev without reset capability.

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-29 13:44:13 +08:00
Edwin Zhai b19d936356 DM: refuse passthrough PCIe without reset support
Check reset method for PCIe dev according to 'reset' in sysfs, which
indicates reset capability, like FLR and secondary bus reset. PCIe dev
without reset capability is refused for passthrough to avoid failure
after UOS reboot.

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-29 13:44:13 +08:00
Huang, Yang c3793e19ed DM sample: update uos launch script for virtio rpmb
Added virtio-rpmb for launch android

Signed-off-by: weideng <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:50 +08:00
Wu, Xiaoguang 9f56364cad DM USB: xHCI: add log level switch
Support log level options, which could change the related log level
without code change.

The new usage:
  -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x]
  eg: -s 8,xhci,1-2,2-2:log=D
  eg: -s 7,xhci,tablet
  eg: -s 7,xhci,1-2,2-2:tablet

Note: please follow the board hardware design, assign the ports
according to the receptacle connection

Change-Id: I44639c7b076d21a40eb8f7b99cea8decc5c13c0c
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang be4406c8d9 DM USB: xHCI: modify option parsing function to enable USB virtualiztion
Re-write the xHCI option parse function to support port mapper.

The new usage:
  -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]
  eg: -s 8,xhci,1-2,2-2
  eg: -s 7,xhci,tablet
  eg: -s 7,xhci,1-2,2-2:tablet

Note: please follow the board hardware design, assign the ports
according to the receptacle connection

Change-Id: I3c8392f7e15580cf768c8c4a619d705411da699d
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 6449950ccc DM USB: xHCI: add xHCI de-initialization support
add support for xHCI de-initialization when the guest
dose shutdown or reboot.

Change-Id: I3dfc1ed1a905b455ef455dff2065e872aa5c1ef8
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 048b2c76a3 DM USB: xHCI: add port sharing feature
add support for xHCI port sharing feature, which enable the ability
to assign different native ports to different multi-UOSes. For
example:
1-2,1-2 assigned to UOS-1.
1-1,2-1 assigned to UOS-2.

Change-Id: I899070f7a8a6eb23179e41e7b1f1da24c52482b2
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 8aef2cb34b DM USB: Add some APIs for check native related configurations.
New USB APIs:
usb_native_is_bus_existed/usb_native_is_port_existed: Check if specific
usb bus or port are valid or not.
usb_native_is_ss_port: Check if the specific port is supper speed usb port.

Change-Id: I9ab54f6e81742321128d6abd5845ef966f0e9f37
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 0181d19a61 DM USB: xHCI: support USB hot plug out.
Implements the disconnect callback of libusb which will be called once
USB device plug out.

Change-Id: Ic5f072f08a92270e6e5836b49e5066da783af243
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 7687a3d0d7 DM USB: xHCI: support bulk and interrupt transfer for port mapper
Support USB mouse, USB keyboard and USB flash drive by enabling the
USB bulk and interrupt transfer for port mapper.

Change-Id: Ia202729e0cfb26fb44a6b278cf4306f2b0b6fa36
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 3b6392740e DM USB: xHCI: DM USB: xHCI: Support port change event for hot connection
This patch implements the port change event related function, it
triggered when USB device be hot plugged in.

Change-Id: I065c1e93779f85f8ee6031960e129b59146e1bb7
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang caf4916e99 DM USB: xHCI: Support control transfer for USB port mapper.
This patch implements the control transfer for port mapper. With this
patch, USB2.0 device can be enumerated successfully in user OS.

Change-Id: I567bd00ca310d68375acd94a5cc5bcd287665df1
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang b12527f35d DM USB: add libusb error conversion function
Add a function to covert libusb error to the common USB core
error type.

Change-Id: Icb03fae2acdc914b3d32a5942faf7d79793a4bee
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 2d1fb7e480 DM USB: move the UREQ macro into common header
move the UREQ macro from usb_mouse.c to usb.h

Change-Id: I977cf73291610b0448eb031a500788a397b55f88
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 17d4e9a995 DM USB: xHCI: implement connect callbacks for USB port mapper
Allocate an emulated USB instance in connect callback function. This
instance is the entity of virtual USB device which will be enumerated
by the UOS.

Change-Id: I948d2ce9eca7e9d5bbab673f2505efc0a03c03b4
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang aa0480f44e DM USB: extend the API for struct usb_devemu
For the purpose of USB port mapper, change struct usb_devemu to
common interface between HCD layer and USB device layer.

Besides, implements ue_init/ue_deinit/ue_info for port mapper.

Change-Id: Id4b7345c7b321b9bdab58139c61169d9229cb6f8
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 1816d3e608 DM USB: introduce data structure and APIs for USB port mapper
Introduce the struct usb_dev which is used to abstract the physical USB
devices. And APIs for external call are also provided.

Change-Id: Ia25d52a6c670040da787f82b3bea34eee9f3d04d
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 51f7633f82 DM USB: involve the libusb
This patch involves the libusb to communicate with the SOS USB kernel
stack, and the README.rst is also updated for this purpose.

The libusb is under GNU Lesser General Public License version 2.1.

Change-Id: Ieecd08f41993162115e8e588980b81b769c89a37
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Wu, Xiaoguang 8f3f66bae5 DM USB: enable log level feature for USB subsystem
Change the DPRINTF macro to UPRINTF for USB subsystem. The
UPRINTF will print log according to certain log level.

Change-Id: I5db8813357c9f684c25f23650e7c914f9063f842
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-29 10:35:05 +08:00
Yonghua Huang 71975d63fd DM: using 'strncpy' coding style cleanup
- check buffer boundaries to avoid buffer overflow

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-25 15:36:25 +08:00
Liu Yuan 0b7af5b6e1 IOC mediator: Implement state transfer operations
This patch implements INIT, ACTIVE, SUSPENDING and SUSPENDED operations of
IOC mediator lifecycle virtualization.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-25 15:34:44 +08:00
Liu Yuan 11208dd6d5 IOC mediator: Implement state transfer framework
Implements state transfer framework to support IOC lifecycle virtualization.
Four states will be involved in this framework includes INIT, ACTIVE,SUSPENDING and
SUSPENDED.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-25 15:34:44 +08:00
Liu Yuan 92da8f4954 IOC mediator: Separate wakeup reason and heartbeat
Separate wakeup reason and hearbeat functions from lifecycle processing since
lifecycle virtualization only contains wakeup reason and heartbeat, the other
functions of lifecycle like boot selector, are not handled by IOC mediator.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-25 15:34:44 +08:00
Huang, Yang 8db85ecb25 DM: RPMB virtualization
Full logic to supprot vRPMB:
1. Automatic switch between physical or simulated RPMB.
   But hardcode to use simulated one.
2. Parse RPMB cmd to basic APIs to:
   2.1 check request frame HMAC with uos vkey
   2.2 replace RPMB frame with real values.
3. RPMB partitioning for multiple UOS.
   It's hardcoded for coming config file support.

Signed-off-by: Huang Yang <yang.huang@intel.com>
Signed-off-by: Du Min <minx.du@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2018-05-25 10:45:24 +08:00
Huang, Yang e6d57f439f DM: Add simulated RPMB support
Create file as simulated RPMB storage for pre-production usage.
Add RPMB APIs to emulate behavior of physical RPMB controllor.

Signed-off-by: Huang Yang <yang.huang@intel.com>
Signed-off-by: Du Min <minx.du@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2018-05-25 10:45:24 +08:00
Qi Yadong 76d2441378 DM: Generate vRPMB key when creating UOS
Generate virtual RPMB key and pass it to HV when
creating UOS.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2018-05-25 10:45:24 +08:00
yingbinx b6bec540f7 VRPMB-BE: add RPMB protocol
This patch implements RPMB protocol into vRPMB backend
VBS-U. It will handle RPMB request from VRPMB FE.

Signed-off-by: weideng <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2018-05-25 10:45:24 +08:00
yingbinx 6c4ebe3f26 VRPMB-BE: create virtio rpmb backend VBS-U
This patch implements virtio rpmb backend VBS-U component,
it includes the basic module interface with DM. This
component will work with vRPMB FE driver together to
provide one communication channel between UOS and SOS.

Signed-off-by: weideng <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2018-05-25 10:45:24 +08:00
Yonghua Huang fc93c649d5 DM: validate port range explicitly in inout.c
- check the port address range explicitly
  to avoid buffer overflow.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-25 09:46:15 +08:00
Jiang, Fei 95c289b15f DM: Change boot_args to assign one plane of pipe B and pipe C to SOS
After i915.avail_planes_per_pipe(0x0000F) is added to SOS, it will cause
that the pipe B/C is initialized without plane. In such case this pipe
can't be used by UOS, with error: primary plane disabled.
The bootarg is changed so that the pipe B/C on SOS can be initialized with
at least one plane.

Signed-off-by: Jiang Fei <fei.jiang@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2018-05-24 21:48:47 +08:00
Miguel Bernal Marin 9563e248b7 samples: move samples to specifi platform diretory
Move the platform apl-mrb samples to devicemodel samples directory.
Add the install target to the missing samples files and re-organize the
samples directory structure to have nuc and apl-mrb samples.

Suggested-by: Arzhan Kinzhalin <arzhan.i.kinzhalin@intel.com>
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
2018-05-24 19:34:49 +08:00
Yonghua Huang 3df0fbfefb DM: bugfix - use of freed memory in 'monitor_close()'
-memory was dereferenced after being freed:
   MACRO 'LIST_FOREACH()' dereference
  'client' for next list node after 'client'
   was freed.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-24 11:13:26 +08:00
Fei Jiang 4c0181a5db DM/GVT: implement emulated graphics pci device
Enable graphics virtualization GVT-g

Signed-off-by: Fei Jiang <fei.jiang@intel.com>
Reviewed-by: He, Min <min.he@intel.com>
2018-05-23 13:11:28 +08:00
Yonghua Huang 160df8433a DM: fix buffer overflow risk issues in hugetlb.c
Add buffer boundaries to avoid overflow

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-23 11:10:10 +08:00
Yonghua Huang cd07c2c9a4 DM: initialize 'create_vm' before reference it in 'vm_open'
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-23 11:09:34 +08:00
Yonghua Huang eb943e7b13 DM:fix the possible buffer overflow issue using 'strncpy'
function 'strncpy' may incorrectly check buffer boundaries
and may overflow buffers.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-22 17:17:26 +08:00
Yonghua Huang 4ed6d92226 DM:fix suspicious dereference of pointer in 'pci_emul_deinit()
suspicious dereference of pointer 'fi->fi_devi'
  by passing it to function 'pci_emul_free_bars()'
  before  NULL check.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-22 17:16:49 +08:00
Yonghua Huang f58fe33687 DM: avoid NULL pointer dereferenced in 'ioc_parse()'
Pointer 'tmp' may be NULL before passing it to 'strtoul()'

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-22 16:37:06 +08:00
Jie Deng 130f45e9cf Revert "dm: free entries in pci_businfo[] when deinit"
This commit is reported to cause UOS reboot fail becasue the
pci_businfo[] only be allocated when calling pci_parse_slot
in dm initialization while UOS reboot will not allocate again.
So we can't free it here.

This reverts commit 7aaff68798.

Signed-off-by: Jie Deng <jie.deng@intel.com>
2018-05-22 11:38:33 +08:00
Yonghua Huang 9e61accbed DM: add spanning devices check for i/o access
- i/o access whose handler is not registered should
  not be allowed.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-18 15:01:35 +08:00
Edwin Zhai 30549a59c7 DM: increase vioapic pin count
Current only 8 vioapic pins for pci irq (total 24 with 16 reserved),
which easily leads virtual GSI sharing with more and more passthrough
devices. This patch doulbes vioapic pin count and adds reboot hooks to
allocate from same pin after each reboot.

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
2018-05-16 15:09:48 +08:00
Geoffroy Van Cutsem 3efef5790c Remove duplicate license file
Remove 'license_header' files that were located in hypervisor/ and
devicemodel/ and used by the respective Makefiles to build the
'include/version.h' header file.

Both Makefiles were adjusted to use the top-level LICENSE file

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-05-16 13:22:17 +08:00
Jie Deng 7aaff68798 dm: free entries in pci_businfo[] when deinit
Entries of pci_businfo[] allocated in function "pci_parse_slot"
using calloc need to be freed when deinit.

Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 18:03:34 +08:00
Yan, Like 867e56d04b Move ACRN tools code directory one level higher
The tools directory is moved out of ./devicemodle, to be in parallel with
hypervisor, devicemodel and doc.

Signed-off-by: Yan, Like <like.yan@intel.com>
2018-05-15 18:03:33 +08:00
Jack Ren 60c07fba51 add .gitignore
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-15 17:41:53 +08:00
Yu Wang 8c06b69622 dm: Reorganize ACRN DM directory.
The current dm, all non-pci and non-acpi related files are put into
hw/platform directory. This is actually disturbed the meaning of
*platform*. The platform devices are mean of board and SoC specific
non-PCI devices, like usb devices, etc.

This patch refines the ACRN dm directory architecture.

For some common device logic files, likes block_if.c/uart_core.c or
usb_core.c. They will move to hw/ directly.

For platform architecture depended files, create arch/ under root dir.
And create sub-dir arch/x86 for x86 architecture, will create more
architectures in future. The pm.c will move to this new dir.

The hw/acpi will be moved to hw/platform/acpi due to acpi also be
considered as part of platform.

Signed-off-by: Yu Wang <yu1.wang@intel.com>
2018-05-15 17:25:58 +08:00
Victor Sun 4817134297 DM: rename acrn_register to acpi_generic_address
The name of acrn_register is too generic, rename to acpi_generic_address
which is more common.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:58 +08:00
Zheng, Gen e386a814ae DM: bug fix in handling signal
With curren code, DM will ignore the SIGHUP signal generated from
SOS reboot that causes DM will not release resource when SOS reboot
occurs.

Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-05-15 17:25:58 +08:00
Long Liu 2550d719d3 Subject: DM: virtio-heci: process all available client each time
Right now, the virtio_heci_proc_rx only process the first
available client at a time, then clear rx_need_sched flag to make
rx_thread sleep. It cause the remain data available clients lost the
current change to be processed. This patch resolves this issue, to
process all data available clients in a round prior to push rx_thread
enter sleep.

Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Long Liu 5ed3dbf93c Subject: DM: virtio-heci: Use atomic_xchange in client get/put
With rare probability, the two threads may try to get&put client
together. For client getting, the subsequent thread will get one
destroyed client. For client putting, it will cause acrn-dm get crashed
due to assert be triggered in virtio_heci_client_put.

Signed-off-by: Long Liu <long.liu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Conghui Chen df2d925a27 DM: move boot device option 'b' just after emul
The original code assume there is only one configuration for
virtio-blk, and 'b' is just located after that configuration,
so to get the value of 'b', it will end char *config by adding
'\0' after the first configuration.

Thus, char *config will change from:
  /XXXX_vdisk_file,range=xxx/xxx
to:
  /XXXX_vdisk_file
and char *b will point to:
  range=xxx/xxx
So, the range will never take effect for virtio-blk.

Now, 'b' is designed to located just after emul, and
char *config will point to all configurations after 'b'.

Note: only ",b," is taken for boot device option.

Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Jian Jun Chen 919aa3d374 dm: virtio-input: implement virtio_input_deinit
All related resources are freed in virtio_input_deinit.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Jian Jun Chen 181ff20bcb dm: virtio-input: implement virtio_input_get_config
The implementation of virtio_input_get_config is based on ioctl of
evdev fd. The following properties of input device are got by ioctl
to service configuation request from FE driver:
- name and devids
- propbit
- evbit: keybit/relbit/absbit/mscbit/swbit
- absbit

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Jian Jun Chen 772a43ac50 dm: virtio-input: implement input event tx/rx
Input events are read from host evdev fd and cached into a local queue.
When SYN_REPORT is read, the cached input events are sent to guest via
EVENT virtqueue. Guest input events are read from STATUS virtqueue then
written to host evdev fd.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Jian Jun Chen 25fe5634d3 dm: virtio-input: implement callbacks of virtio_input_ops
This patch implements the callbacks required by virtio_input_ops:
reset/cfgread/cfgwrite/apply_features/set_status.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Jian Jun Chen 9741e1ab2c dm: virtio-input: implement virtio_input_init
The following are done in virtio_input_init:
- parse the command line to get the path of host evdev
- parse the command line to get the optional serial string
- calloc struct virtio_input and initialize it
- call virtio framework APIs to initialize virtio PCI

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Jian Jun Chen 8123483ae1 dm: virtio-input: add virtio-input data structures
This patch adds the data structures and macros used to implement
virtio-input.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:58 +08:00
Victor Sun 3fc5ebcd50 DM Cx: build DSDT with cx data
With this patch, UOS would be capable of guest Cx controling.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:57 +08:00
Victor Sun 5e7e816981 DM Cx: add function to write Cx data to DSDT
The function would write CST objects which needed to enable Cx control
to UOS DSDT table.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:57 +08:00
Victor Sun a042538565 DM Cx: add function to get cx cnt and cx data
DM will use these functions to get cx entry cnt and cx data then inject
_CST objects to UOS DSDT table.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:57 +08:00
Victor Sun bdd90e6597 DM Cx: code cleanup for getting cpu state cnt
Then we could use a common interface to get cx count.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:57 +08:00
Yin Fengwei 81cf3e19f8 DM: main loop cleanup
Move all virtual devices init/deinit to function to simplify the
failure path of main loop. In the future, new virtual device will
not touch main loop.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-15 17:25:57 +08:00
Yin Fengwei edc584611a DM: ioc code cleanup
- make ioc_init/ioc_deinit take struct vmctx as argument
- ioc_init return int instead of pointer to struct ioc_dev
- add ioc_dev in vmctx to track ioc_dev
- remove the atkbdc.h included in vmmapi.h

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Liu, Yuan1 <yuan1.liu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-15 17:25:57 +08:00
Yin Fengwei 4fcdebc434 DM: vrtc code cleanup
- Move the variable local_time from main.c to rtc.c
- Change vrtc_init to return int instead of pointer to vrtc. We do
  track vrtc in struct vmctx.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:57 +08:00
Icarus Sparry 7073173ec3 Use exit instead of assert when checking images
Print an error message and exit rather than using assert, so it is
more obvious what the problem is and no core files are produced.

Fixes #61

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2018-05-15 17:25:57 +08:00
Jie Deng d63b9002dd dm: code clean up
Following functions have never been used anywhere.
Let's remove them.

fbsdrun_muxed()
fbsdrun_vmexit_on_hlt()
fbsdrun_vmexit_on_pause()
fbsdrun_disable_x2apic()

Remove weird prefix "fbsdrun" from following functions' name.

fbsdrun_virtio_msix()  -->  virtio_uses_msix()
fbsdrun_start_thread() -->  start_thread()

Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:57 +08:00
Jie Deng d1a17a6401 dm: rename fbsdrun_addcpu and fbsdrun_deletecpu
Remove weird prefix "fbsdrun" from the function name.
Since "fbsdrun_addcpu" has never been called by external
functions, Let's remove its declaration from "dm.h" and
make it as a static function to keep consistency with
"fbsdrun_deletecpu".

Signed-off-by: Jie Deng <jie.deng@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:57 +08:00
yuhong.tao@intel.com 15e15c9a86 Bugfix: DM:tools:acrnctl launch script output is binary file
The launch script can output log messages, that should be text.
But it is not always true. E.g. "launch_UOS.sh -U 2" echo message
contain '\0', The 'grep' command will show "Binary file (xxxxxx)
matches", thus acrnctl can't get the vmname. We can use 'grep -a'
instead.

Acked-by: Xu Anthony <anthony.xu@intel.com>
Reviewed-by: Yan Like <like.yan@intel.com>
Reported-by: Chen ChengX <chengx.chen@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-05-15 17:25:56 +08:00
Yin Fengwei d2945e757e DM: fix virtio_net tx_thread block issue
If guest doesn't initialize the net device, the tx thread will
block at the first tx_cond wait. When virtio_net_tx_stop is
invoked, the tx_thread will block on second tx_cond then.

Check whether we should exit tx_thread after first tx_cond
waiting

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:56 +08:00
Liu Yuan cb41210104 IOC mediator: update signal whitelist
Add AmbientTemperature signal into the whitelist,
instead of TemperatureSensorEnvironment signal.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:56 +08:00
Liu Yuan 10c3a98577 IOC mediator: update signal whitelist
Remove some useless signals from the whitelist and add new three signals into
the whitelist based on requirement.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:56 +08:00
Edwin Zhai 3648a0cd6f VTd: bluetooth passthrough support
Adds ACPI tables for 0:18.0(UART) device

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:56 +08:00
Jason Chen CJ 4f6bdee0c5 DM: change VM_SYSMEM/VM_MMIO to VM_MEMMAP_SYSMEM/VM_MEMMAP_MMIO
these MACROs are only for MEMMAP

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-05-15 17:25:56 +08:00
Jason Chen CJ 25ef14edac hugetlb: add ept map memseg support
adding API vm_map_memseg_vma() which using ioctl IC_SET_MEMSEG call
into VHM for futher mem(ept) mapping, based on user vma information.

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Jason Chen CJ 4cad694be2 dm: add hugetlb memory management support
Type '-T' in DM cmdline to enable hugetlb memory allocation.
It enabled 2 level of huge page:
Level 1: size 2M, path: /run/hugepage/acrn/huge_lv1/guid
Level 2: size 1G, path: /run/hugepage/acrn/huge_lv2/guid

NOTE:
before running, please make sure system already have enough hugepages
reserved under:
/sys/kernel/mm/hugepages/hugepages-xxxxkB/nr_hugepages

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Minggui Cao fdfb71e075 delete watchdog timer when deinit is called
to avoid system resource/memory leaked when guest os reboot.

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:55 +08:00
Jian Jun Chen a3316241d4 dm: virtio-console: Fix the bug that ports cannot work
If multiple ports are defined in the command line, is_console is
not set to a correct value for non-console ports when the definition
of this non-console port is following the definition of a console port.
For example in below definition, the second port is configured as
console port which is not correct:

-s 5,virtio-console,@pty:pty_port,file:file_port=/home/root/test1

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Yin Fengwei 96085d960f DM: release mem range allocated in init_pci
Two memory ranges are allocated:
  - PCI ECFG
  - PCI hole
They should be released when deinit_pci. Old code mark
this two ranges not unregistered. Which is wrong for
warm reboot case. Make them could be unregistered.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Yin Fengwei 097aee76bf DM: release mevent when doing virtual device deinit
When doing warm reboot, the mevent module will not be deinitialized.
We need to delete all mevent registered while deinit virutal device.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Yin Fengwei e65b98bf36 DM: lpc_deinit doesn't release all resources allocated.
Also refine the failure path of lpc_init to make sure all
resources allocated get release.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Yin Fengwei 1a2a07476b DM: cleanup resource for uart.
Add deinit function for uart.
Another work is add resource cleanup functions which is called
by other components when they are using uart.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Yin Fengwei c8585a22e3 DM: add deinit function for bvmcons
Move the bvmcons enable flag from main.c to consport.c.
So we don't need the flag in main.c for bvmcons.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:55 +08:00
Liu Yuan 5b06d17fb1 IOC mediator: boot IOC device from the main entry
Add "-i" in the DM boot command line for booting IOC mediator.

NOTE: currently only ioc_init will be called in the main entry, ioc_deinit
hasn't be called so far. The DM plans to add one virtual devices list inside
of struct vmctx in the near furture, and virtual devices data structure will
add one common deinit callbacks which will be called during VM exits.

Will support ioc_deinit once that patch merged.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan fd5472b421 IOC mediator: DEBUG: add dummy channels
Add three PTY devices as dummy native channels. They are used for emulating
native lifecycle channel, native signal channel and native OEM raw channel
for IOC debugging.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan 75b5e670d5 IOC mediator: DEBUG: support IOC log file
This patch is used for IOC mediator debugging. Due to IOC message logs are
too much, need to save into one file instead of output stdout directly.
By default, the debug log is disabled.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan 746d437642 IOC mediator: support IOC signal whitelist
This patch implements the signal whitelist feature.
All the signal messages will be discarded if they are not existed in whitelist.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan 76e74b0cf8 IOC mediator: support CBC signal services
This patch implements the IOC CBC signal serivces including single signal,
multi-signal and group signal. All of them are used for CAN devices
communication and IOC on-board peripherals control.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan 61db2c78cc IOC mediator: support IOC lifecycle
This patch implements the IOC lifecycle virtualization.

In native environment, lifecycle is uesed for SoC system power control,
likes enter/exit S3/S5. So these related messages can not forward directly
between physical IOC and Guest OS, they need to be mapped to VM pause, exit
and launch.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan a1d7cae148 IOC mediator: IOC signal and group definitions
This patch adds the IOC signal identities and signal group identities,
that will be used by subsequent signal support patches.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan 4eff8d10a1 IOC mediator: implement CBC protocol stack
Carrier Board Communication(CBC) protocol is a duplex protocol for IOC data
transfer, including physical layer, link layer, address layer and service layer.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan c9d7643462 IOC mediator: add IOC channel operations
IOC mediator communicates with native IOC HW through several native channels of
CBC protocol. And IOC mediator communicates with virtual UART through one virtual
channel.

This patch implements channel operations including open/close/read/write.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan cfa6481bc9 IOC mediator: initialize IOC mediator
IOC mediator main functionality is transfer data between native CBC char
devices and virtual UART, it is implemented as full virtualization, Guest
OS can reuse native CBC driver directly.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Liu Yuan 45758be573 IOC mediator: add IOC mediator definition
Add Automotive IOC mediator data structure definitions.

Signed-off-by: Liu Yuan <yuan1.liu@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:54 +08:00
Jack Ren f3db18b981 version: v0.1-rc4
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-15 17:25:50 +08:00
Yin Fengwei c6bf67543c DM: mevent_add/del refine for Linux
Unlike kqueue/kevent of BSD, the epoll of Linux could be
add/del by using different API on the fly.

This patch drops the notify used by mevent_add/del and
call epoll_ctl to add/delete target fd. Only keeps
global_head to track mevent added and makes the code
logic in mevent_dispatch() a littel bit simpler.

Another thing is related with epoll_ctl. If the target
fd is regular fd which doesn't support epoll, epoll_ctl
will return -1. When DM is start by systemd, the STDIO
is not mapped to terminal, epoll_ctl on STDIO could
return -1. Which block UOS boot. We only call mevent_add
after confirm STDIO is mapped to terminal.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:27 +08:00
Yin Fengwei db46df940e DM: add init/deinit function for mevent
Current, mevent cleanup path has issue. There are possible
following calling sequence happen when reboot/poweroff UOS:
 1. mevent_dispatch() calls mevent_destroy
 2. do_close_post calls some virtual device deinit to delete
    mevent.

This patch introduce mevent init/deinit to make sure:
 1. mevent init
 2. mevent_add is called when init virtual device
 3. mevent_del is called when deinit virtual device
 4. mevent deinit

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:27 +08:00
Yin Fengwei d3a640da92 DM: add add_e820_entry to update e820 table.
For vSBL boot path, we need to mark the memory vSBL is using
as reserved in e820 table. The add_e820_entry is added to
update the e820 table dynamically.

To simplify the code logic, we assume:
  - vSBL is put the middle of one entry of default e820 table
  - That entry has orignal RAM type in e820 table
  - The e820 table has enough space to hold two more new entries.

If there is more complicated case in the future, we could extend
add_e820_entry to handle it.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:26 +08:00
Yin Fengwei 223efeb986 DM: Update the default e820 table to reserve 0xF0000~0x100000
The region of MPtable/ACPI table/SMBios resides in
0xF0000 ~ 0x100000. They should be marked as RESERVED instead of
RAM type in e820 table.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo ee43f23b0e dm: release host memory after devices de-init
Devices' de-init process might access some mapped memory space, such as
virtio virtqueues. Access after unmap will cause a fault.

Release the memory map after de-init processes can avoid it. Reading
more code, there are many error handling lost to unmap the memory.
Refined the code to do it.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:26 +08:00
Yin Fengwei cee499f867 DM: fix build issue with gcc 4.8.4 on ubuntu 14.04
There are two build issues:
- add -fno-strict-aliasing to address
  error: dereferencing type-punned pointer will break strict-aliasing rules

- initialize tfd to zero to address
  error: ‘tfd’ may be used uninitialized in this function

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:25:26 +08:00
Qi Yadong e86b01f57e Revert "Fix compilation on Ubuntu 14.04"
This reverts commit bc0579d0ff.

The commit bc0579d makes acrn-dm crashed when launch UOS.
Crash log:
./launch_UOS.sh: line 112:   377 Segmentation fault (core dumped) acrn-dm ...
dmesg log:
acrn-dm[1264]: segfault at 1f0 ip 0000000000412257 sp 00007fffc1af9920 error 6 in acrn-dm[400000+3d000]

After this patch reverted, UOS launched successfully.
2018-05-15 17:25:26 +08:00
Liu Shuo c5b14c2646 DM: use standard offsetof to avoid duplicate definition
Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo d9545abefb virtio-heci: disconnect client when message buffer overflowed
Firmware need to disconnect the client connection when host's message
overlow the receive buffer in firmware. We emulate this behavior in
backend service.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Li Hao <hao.l.li@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo 33e84efef9 virtio-heci: Add firmware reset handling
Now, we treat a read/write ENODEV error as a firmware reset. When MEI
reset happens in driver, we need disconnect all active clients and
restart HBM flow.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Li Hao <hao.l.li@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo 37cae5884d virtio-heci: Add HBM handler for backend service
HECI Bus Message is important for HECI clients communication. They use
HBM for connect, disconnect, get property and so on. In backend service,
we need do some emulation for HBM as we are running on top of native
MEI driver.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Li Hao <hao.l.li@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo 12b9299ff6 virtio-heci: Introduce TX and RX threads for data transfer
Backend service access the native HECI driver through MEI driver
interface in service OS. Some MEI clients need to be multiplexed,
the backend service will engage necessary service at clients filter.

TX thread is for passing data from guest to host MEI driver, then to
native hardware. RX thread is for passing data from native hardware to
guest.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Li Hao <hao.l.li@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo 418c266bfc virtio-heci: Add ME client mapping in backend service
ME client mapping is for tracking ME clients operations between frontend
driver and backend service. It contains buffers for send/recv packing
and forwarding.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Li Hao <hao.l.li@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
Liu Shuo 23c3fbd485 virtio-heci: Backend service for HECI virtualization
This patch implement HECI virtualization backend service based on virtio
userspace framework. This service introduce a virtio-heci device model
for DM, and can be enabled by DM parameter '-s [BUS NO],virtio-heci'.

The HECI virtualization need both backend service in device-model and
frontend driver in guest to work. Backend service mainly emulates HECI
device's behaviors to satisfy frontend driver. They are based on virtio
userspace framework. Currently, it is using two virtqueues, one is for
TX and another is for RX.

Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
Reviewed-by: Li Hao <hao.l.li@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
Geoffroy Van Cutsem 473f222dce Add 'findutils' to Fedora-based Docker images
The 'find' command was not installed in our minimal Fedora 26
and 27-based Docker images. This resulted in a non-fatal error
when performing a 'make clean'. This commit adds this utility
(available in the 'findutils' package).

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-05-15 17:25:26 +08:00
Geoffroy Van Cutsem da1c860e8c Fix compilation on Ubuntu 14.04
A couple of problems appeared on Ubuntu 14.04 (gcc 4.8.4) when we
turned on additional compiler flags with commit
519c4285cf104a594776591075ee1c6ee4d61815a. This patch fixes these
problems by adhering to the strict anti-aliasing rules and also
initializing the 'tfd' variable where the compile believed it
_could_ be used uninitialized.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:25:26 +08:00
Mingqiang Chi 4f6c451278 dm: sync common header file to DM
sync acrn_common.h to device model
set secure world enabled flag

Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:26 +08:00
yechunliang 2e2f02edeb replace malloc with calloc
malloc: allocate a block of memory, the contents of the block are undefined.
calloc: allocate a block of memory for an array of num elements and initializes all its bits to zero.

Signed-off-by: yechunliang <yechunliangcn@163.com>
2018-05-15 17:25:26 +08:00
Victor Sun e078ce7aae DM: hotfix for loop initial declaration in acpi_pm
for (int i = 0; i < ...; i++) is only allowed in C99 mode, so fix this
coding style to:

int i;
for (i = 0; i < ...; i++)

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:25 +08:00
Victor Sun a91118e3e8 DM: build UOS DSDT with vcpu px state data
With the DSDT which include virtual _PSS/_PCT/_PPC objects, UOS should
have ACPI Px control capability if acpi cpufreq driver is enalbed in
kernel.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:25 +08:00
Victor Sun e96fe060bc DM: add vmctx as write dsdt func ptr parameter
Some ACPI objects is per-vm and per-cpu specific so we need to pass
vmctx as function parameter when we write objects into DSDT table.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:25 +08:00
Victor Sun b50fcc022f DM: add function to write Px objects to UOS DSDT
There are 3 ACPI objects for Px: _PCT, _PPC and _PSS need to be writed
to DSDT, and the _PSS data is per-cpu specific so we need to pass the
vm id and vcpu id as parameter.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:25 +08:00
Victor Sun ea662e6d49 DM: add function of get px count and data
The px count and data is per-cpu so we should query them for specific
vm and specific vcpu, for px data we need to specify px num also.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:25 +08:00
Victor Sun 263bdf6cf2 DM: add vmm interface to get px data
The interface will be used to interact with VHM service via IOCTL.

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:25:25 +08:00
Tao, Yuhong 4e5029383d DM:tools: add acrnctl tool
The acrnctl can help user to create, delete, launch and stop UOSs,
To see what it can do, just run:
	# acrnctl
or
	# acrnctl help
you may see:
	support:
        	list
        	start
        	stop
        	del
		add
	Use acrnctl [cmd] help for details
There are examples:
(1) add a VM
    Each time you can just add one VM. Suppose you have an UOS
    launch script, such as launch_UOS.sh
    you can run:
	# acrnctl add launch_UOS.sh -U 1
	vm1-14:59:30 added
    Note that, launch script shoud be able to launch ONE UOS. If
    it fail, it is better to print some error logs, to tell user
    the reason, so that he knows how to solve it.
    The vmname is important, the acrnctl searchs VMs by their
    names. so duplicated VM names are not allowed. Beside, if the
    launch script changes VM name at launch time, acrnctl will
    not recgonize it.
(2) delete VMs
	# acrnctl del vm1-14:59:30
(3) show VMs
	# acrnctl list
	vm1-14:59:30            untracked
	vm-yocto            	stop
	vm-android		stop
(4) start VM
    you can start a vm with 'stop' status, each time can start
    one VM.
	# acrnctl start vm-yocto
(5) stop VM
    you can stop VMs, if their status is not 'stop'
	# acrnctl stop vm-yocto vm1-14:59:30 vm-android

Acked-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
Signed-off-by: Tao, Yuhong <yuhong.tao@intel.com>
2018-05-15 17:25:25 +08:00
Tao, Yuhong 498e8c0543 monitor: an interface of acrn-dm
A monitor component will be added to acrn-dm, which crteats socket,
bind and listening at /run/acrn/vmname. Acrnctl & acrnd could conn
-ect to the socket for communication, using defined message, in
include/monitor_msg.h
For each defined message, a message handler callback could be
registered via monitor_add_msg_handler(). On received of a defined
message, a certain call back will be called. Each callback can only
see the message sender's socket-fd.
When acrn-dm want report something, not triggered by incoming message
it can send broadcast message, use monitor_broadcast().

Acked-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Yin, Fengwei <fengwei.yin@intel.com>
Signed-off-by: Tao, Yuhong <yuhong.tao@intel.com>
2018-05-15 17:25:25 +08:00
Geoffroy Van Cutsem 1ef6bba51e Enable Travis CI testing
Enable Travis CI testing for the following development host OSs:
* Clearlinux
* Ubuntu 16.04
* Fedora 26

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-05-15 17:25:25 +08:00
Yin Fengwei eadc921bf0 DM: refine cleanup functionality of virtual RTC
The patch includes:
1. vrtc_cleanup -> vrtc_deinit to align with other devices
2. delete timer created in vrtc_init
3. make call to vrtc_deinit in cleanup path

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Yin Fengwei 80a9fe5b37 DM: add deinit function to virtual keyboard device
old code has no deinit functionality for virtual keyboard device.
Which will trigger resource leak when system is reboot.

deinit function is added to:
1. deinit low ps2 based keyboard and mouse
2. release memory/io resource of virtual keyboard device
NOTE: IRQ resource will be handed in pci irq module

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Yin Fengwei f6db755c7f DM: add deinit function for ps2kbd and ps2mouse
Add deinit function for ps2kbd and ps2mouse.

To support deinit function for ps2kbd and ps2mouse which
has struct atkbdc_base as parameter, we make struct
atkbdc_base exported as public.

We also add console unregister function for keyboard
and mouse. Which are called in ps2mouse/ps2kbd deinit
function.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Yin Fengwei f0b74016d1 DM: release mmio data structure for pci bar
We didn't release mmio/io data structure related with PCI bar
of pci dev. Which could trigger memory leak when reboot UOS.

With the new patch, we release the mmio/io data structure
when pci core tries to deinit pci device.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 86f394851b dm/VBS-U: increase generation when configuration changed
Virtio 1.0 introdues a generation number for the device-specific
configuration. It should be increased every time the configuration
noticeably changes.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 0398498846 dm/VBS-U: implement virtio_dev_error
When the device has experienced an error from which it cannot
re-cover, DEVICE_NEEDS_RESET is set to the device status register
and a config change intr is sent to the guest driver.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen ce098260de dm/VBS-U: implement virtio_vq_enable
Virtio modern changed the virtqueue cofiguration precedures. GPA
of descriptor table, available ring and used ring are written to
common configuration registers separately. A final write to
Q_ENABLE register triggered initialization of the virtqueue on
the backend device.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 76422fd5f1 dm/VBS-U: implement write callback of notify cfg
virtio_notify_cfg_write is called when guest driver performs virtqueue
kick by writing the notificaiton register of the virtqueue.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen cfa591aedf dm/VBS-U: implement read callback of isr cfg
Registers in the isr configuration region are read-only.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 1fa2f27dd3 dm/VBS-U: implement read/write callbacks of device-specific cfg
This patch implements the read/write callbacks for the registers in the
device-specific region. This region is implemented in the modern MMIO
bar.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen a098c11869 dm/VBS-U: implement read/write callbacks of modern common cfg
This patch implements the read/write callbacks for the registers in the
common configuration region. This region is implemented in the modern
MMIO bar.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 2adac78d4f dm/VBS-U: implement generic PCI barread/barwrite
This patch implements the generic PCI barread/barwrite callbacks.
Specific barread/barwrite interfaces are called based on the baridx.
Virtio legacy devices, transitional devices and modern devices can
be handled in an unified way.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 5670f33278 dm/VBS-U: implement virtio_set_modern_bar
virtio_set_modern_bar is an external interface that backend virtio
driver can call to initialize the PCI capabilities and PCI bars
defined in the virtio 1.0 spec.

The following are done in the function:

- 5 PCI capabilities are added to the PCI configuration space of the
  virtio PCI device. (common/isr/device_specific/notify/cfg_access)

- A 64-bit MMIO bar is allocated to accommodate the registers defined
  in the 4 PCI capabilities. (cfg_access capability does not require
  MMIO.)

- If use_notify_pio is true, a PIO notify capability is added to the
  PCI configuration space and a PIO bar is allocated for it
  accordingly.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 9c2378f19e dm/VBS-U: expand data structures to support virtio 1.0
Struct virtio_base and struct virtio_vq_info are expanded to support
virtio 1.0 framework. The BAR layouts of virtio legacy/transitional/
modern are introduced as well.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 5e613efd95 dm/VBS-U: add virtio 1.0 data structures
This patch adds virtio 1.0 data structures and macros according to
virtio spec v1.0 cs4. Part of them are referenced from Linux's
BSD-licensed include/uapi/linux/virtio_pci.h

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:24 +08:00
Yonghua Huang de4d793389 Remove 'noxsave' bootarg in dm sample script
xsave feature is enabled in hv and exposed to uos

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-15 17:25:24 +08:00
Jian Jun Chen 70625f04d3 dm: export pci_emul_add_capability
pci_emul_add_capability is needed by virtio 1.0 framework to add
pci vendor capability from outside of pci core.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Yin Fengwei f1e801dfeb DM: Add long option to enable trusty
The trusty enabled or not will be passed to HV
with create vm hypercall. It's passed to vSBL within
config page also.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:25:23 +08:00
Yan, Like 731c0d41f9 DM:tools: add README.rst for acrnlog tool
Signed-off-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Yan, Like a1c07bb9b0 DM:tools: add service file for acrnlog
acrnlog should run automatically at boot.

Signed-off-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Yan, Like 8c91847401 DM:tools: add acrnlog tool
acrnlog is an SOS userland tool to capture ACRN hypervisor log
to /tmp/acrnog/. Two kinds of logs would be saved:
 - log of current running;
 - log of last running if crashed and logs remaining.

[Usage] acrnlog [-s] [size] [-n] [number]

[Options]
	-h: print this message
	-s: size limitation for each log file, in MB.
	    0 means no limitation.
	-n: how many files you would like to keep on disk

Signed-off-by: Yan, Like <like.yan@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Yan, Like 466eb13054 DM:tools: add README.rst for acrntrace
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Yan, Like e09208b7d7 DM:tools: add scripts for VM exit analysis
Script usage:
[Usage] acrnalyze.py [options] [value] ...
[options]
-h: print this message
-i, --ifile=[string]: input file
-o, --ofile=[string]: output file
--vm_exit: to generate vm_exit report

Note: bash and python2 are required.

Example:
Assumed trace data have been copied to /home/xxxx/trace_data/20171115-101605
 # acrnalyze.py -i /home/xxxx/trace_data/20171115-101605/0 -o /home/xxxx/trac
   e_data/20171115-101605/cpu0 --vm_exit

 - "--vm_exit" specify the analysis to do, currently, only vm_exit analysis
   is supported.
 - A preprocess would be taken out to make the trace data start and end with
   an VM_ENTER, and a copy of original data file is saved with suffix ".orig";
 - Analysis report would be given on the std output and in a csv file with
   name specified via "-o outpu_file";

Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Yan, Like 99c69c7773 DM:tools: add acrntrace tool
acrntrace: is an debug tool running on SOS to capture trace data.

Usage:
1) Start tracing
  Capture buffered trace data:
  # acrntrace
  or clear buffer before tracing start:
  # acrntrace -c

  A folder will be created to save the trace data files are under
  /tmp/acrntrace/, named with time string.
  Eg: /tmp/acrntrace/20171115-101605
2) Stop tracing
  # q <enter>

Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 17:25:23 +08:00
Jack Ren c730806a36 version: v0.1-rc3
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-15 17:25:17 +08:00
Jack Ren a9ba43921e update home page information
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-15 17:19:39 +08:00
Yin Fengwei 0d9d628d9a DM: add option to show which virtio-blk is boot device.
Now, we could use option:
 -s 3,virtio-blk,/XXXX_vdisk_file,b
to show this virtio device is boot device for guest.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:19:38 +08:00
Yin Fengwei 53b89b91de DM: add long option to specify guest partition info file
Some guests needs guest partition info passed to support
A/B boot. DM needs to load guest partition info from file
and pass to vsbl.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:19:38 +08:00
Yin Fengwei 1e13533ec0 DM: Enable vsbl boot path.
There are two things here:
1. Enable basic vsbl boot functionality.
2. add long option to DM to specific vsbl file. So DM could
   choice to boot guest with vsbl.

It's hard to find a suitable short option. So only long option
is supported for vsbl file name option.

If long option "--vsbl='vsbl_file_name'" is given in DM
commandline, the "vsbl_file_name" will be loaded by DM
first and running. vsbl will be response to lead guest to
next boot stage.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:19:38 +08:00
Yin Fengwei 860c2cab3e DM: export acpi table base address and length.
Will update e820 table to mark the address ACPI specific type.
Also need pass ACPI table start address and size to vsbl.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-05-15 17:19:38 +08:00
Yin Fengwei 446297f96d DM: sw_load: sw_load function name update
To align with file name, acrn_sw_load_direct() is changed
to acrn_sw_load_bzimage().

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:19:38 +08:00
Yin Fengwei 01c8053dfb DM: fix build error with gcc-8.
gcc8 showed following errors when build DM:
  error: argument to ‘sizeof’ in ‘strncpy’ call is the same
  expression as the source; did you mean to use the size of the
  destination? [-Werror=sizeof-pointer-memaccess]

It looks like wrong parameter was given to strncpy.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-05-15 17:19:38 +08:00
Tianhua Sun edcd8f0243 Makefile cleanup
remove TARGET_YOCTO
replace "=" with "?=" if variable is defined, don't redefine.

Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
2018-05-15 17:19:38 +08:00
Yin Fengwei 6ee72d7df9 DM: split sw_load.c to sw_load.c and sw_load_direct.c
The common loader code is put to sw_load_common.c
The loader code for directly kernel loading is put to sw_load_bzimage.c
The further change for SBL will be put to sw_load_sbl.c

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:19:38 +08:00
Liu Shuo 544ec38b97 Fix string may be truncated issue with using snprintf
New compiler options introduced by commit
519c4285cf will cause DM compile failure
which caused by warnings from some snprintf usage might be truncated.

Expanding the string buffer to make compiler happy.

v3: change format string
v2: Address comment from Hao, shrink bident string size to satify
tname length in blockif_open.

Signed-off-by: Rusty Lynch <rusty.lynch@intel.com>
Signed-off-by: Liu Shuo <shuo.a.liu@intel.com>
2018-05-15 17:19:38 +08:00
Shuo Liu 2205d5e0e8 virtio: config changed notify interface
Some virtio PCI devices can change the device configuration state, as
reflected in the device-specific configuration region of the device. In
this case:
 * If MSI-X capability is disabled:
    1. Set the second lower bit of the ISR Status field for the device
    2. Send the appropriate PCI interrupt for the device.
 * If MSI-X capability is enabled:
    1. If config_msix_vector is not NO_VECTOR, request the appropriate
       MSI-X interrupt message for the device, config_msix_vector sets
       the MSI-X Table entry number.

A single interrupt MAY indicate both that one or more virtqueue has been
used and that the configuration space has changed.

Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
2018-05-15 17:19:38 +08:00
Shiqing Gao 819845c9bd dm: add ACPI info for ipu pass-through
IPU devices are using I2C device with physical BDF 0:16.0.
The I2C controller has the dependency on ACPI info.
This patch is to add ACPI info for the I2C controller and the two IPU
devices that are under the scope of I2C.

Note:
This patch is specific for GP platform.

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2018-05-15 17:19:37 +08:00
Yin Fengwei 23efb5a0e9 DM: reboot: clear the data of 0xcf9 if cold reboot
Linux kernel CF9 reboot is doing things like:
  - read value from 0xcf9
  - mask out the value according to the reboot type (warm vs cold)
  - BIT OR the value with reboot code
  - write the value to 0xcf9

If there are two reboot event and the first one is cold
reboot and the second one is warm reboot, vsbl query
reboot type after the second one and will get code reboot
instead of warm reboot.

We should clear the data of 0xcf9 if guest request cold reboot.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:19:37 +08:00
Yin Fengwei 66ddb67bdd DM: acpi: Update the reset value of FADT to trigger cold reboot
There are bootloaders require cold reboot as ACPI reboot
instead of warm reboot.

So we set 0xE to reset value of FADT to make ACPI reboot
cold reboot.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:19:37 +08:00
Yonghua Huang b6d73be1a6 Enable FORTIFY and FORMAT SECURITY compile flags
1. Enable below 2 defenses in Makefile
   "-O2 -D_FORTIFY_SOURCE=2"
   "-Wformat -Wformat-security"

2. Update related source code impacted by above 2 flags

Change-Id: Ib42214848f030b4cf508cd7c52a7e3cc809435d9
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-15 17:19:37 +08:00
David B. Kinder ed78db46ab update launch_uos.sh script
Documentation says to use CL version 21260, but sample script wasn't
updated.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 17:19:36 +08:00
Yin Fengwei 3775f29e3c vm: Pass uuid from DM commandline to vm as GUID.
Also save the uuid to ctx in case DM needs to access the
uuid.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:19:36 +08:00
David B. Kinder 81c47e776e add .gitignore
create a .gitignore that ignores build output created by make

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 17:19:36 +08:00
wenshelx d92f640829 security: data relocation and protection(RELRO)
RELRO rearranges the data sections inside an ELF
executable. It also marks certain areas as 'read-only'
so that these data structures cannot be overwritten while
the process is running.

Tracked-On: 224003
Signed-off-by: wenshelx <wenshengx.wang@intel.com>
2018-05-15 17:19:36 +08:00
wenshelx 156d61e20f security: enable stack protector
Enable stack-proctector-strong option for gcc emiting
extra code to check buffer overflow.

Enable noexecstack option for marking the object as not
requiring executable stack.

Tracked-On: 224003
Signed-off-by: wenshelx <wenshengx.wang@intel.com>
2018-05-15 17:19:36 +08:00
Yin Fengwei f86d91e1e1 dm: use getopt_long instead of getopt to parse dm cmdline
It will be easier if we want to add more command line options
with long options.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-05-15 17:19:36 +08:00
Shuo Liu 44b0ec0413 Ignore length of resource for PCI ROM request
Writing PCIR_BIOS is to get PCI ROM resource length. Ingore the request
as it's not support currently. Else, guest might get wrong information
about the PCI ROM resource.

Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
2018-05-15 17:19:35 +08:00
Jack Ren cf707cc62e version: v0.1-rc2
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-15 17:19:22 +08:00
Jack Ren 955162bb3a minor fix on sample script bridge.sh
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-11 14:44:30 +08:00
Geoffroy Van Cutsem 32fbc357bc README.rst: convert to ReST and add details
* Convert the README file to reStructuredText (ReST)
* Add more details (such as build dependencies) for Fedora 27

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-05-11 14:44:29 +08:00
Jason Chen CJ e404760cd2 add RC_VERSION for dm
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-05-11 14:44:29 +08:00
Miguel Bernal Marin 3b15f510c7 makefile: install the demo scripts
The demos scripts are not installed when "make install" is invoked.
This patch adds a rule to copy them to /usr/share/acrn

Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
2018-05-11 14:44:29 +08:00
Jack Ren 1f0fe2d15f update Maintainer list
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-11 14:44:28 +08:00
Anthony Xu bd31b1c53e initial import
internal commit: 0ab1ea615e5cfbb0687a9d593a86a7b774386076

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
2018-05-11 14:44:28 +08:00