Commit Graph

1561 Commits

Author SHA1 Message Date
Yonghua Huang c597a0fc2f I/O VM-exit handler cleanup
- add check for spanning i/o devices access
- remove ASSERT in I/O instr. VM exit handler

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-15 18:03:33 +08:00
Zhao Yakui 9efbf1212f HV: Enable the -O2 option for HV
Now the -O0 option is used. In such case the code is not optimized.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Zheng Gen <gen.zheng@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-05-15 18:03:33 +08:00
Zhao Yakui 263fafe819 HV: Initialize one variable to fix the compiling warning
If the optimization option is enabled, it is possible that one variable is
not initialized before using in the get_vioapic_info. (In fact the warning is
bogus)
This is only to reduce the compiling warning.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2018-05-15 18:03:33 +08:00
Zhao Yakui 3a9bf54d66 HV: Add gcc compiler option to disable FPU/SSE/MMX
FPU/SSE is not supported in HV. Otherwise it is possible that the
SSE/FPU register is used under -O2 option.
So the gcc option is added to disable them.

Signed-off-by: Zhao Yakui <yakui.zhao@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-05-15 18:03:33 +08:00
Zhao Yakui 52a91fff0d HV: Use the CFLAGS to control the optimization option
Now two flags can be used to control the optimizatin option. So unify them
and only one flag can be used to config the optimization

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Zheng Gen <gen.zheng@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-05-15 18:03:33 +08:00
Zhao Yakui 698b53adc4 HV: Add one correct Descriptor_table struct to configure VMCS
Now one uint64_t type is used to obtain the corresponding descriptor_table
for GDT/IDT. This will cause the stack protect corruption under -O2.
So the descriptor_table struct is added to configure the GDT/IDT of VMCS.

V1->V2: Move the descriptor_table into vmx.h header file
And its type is renamed from dt_addr_t to descriptor_table.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Zheng Gen <gen.zheng@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-05-15 18:03:33 +08:00
Zhao Yakui b2cadfecdf HV: Fix the incorrect operand-constraints for inline assembly
The RFLAGS will be touched in some inline assembly.(exec_vmxon/
RFLAGS_RESTORE). The "cc" constraint should be added. Otherwise
it won't be handled under -O2 option.
And "%%XXX" register should also be added into constraints.
Otherwise it will be optimized incorrectly.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Zheng Gen <gen.zheng@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-05-15 18:03:33 +08:00
Li, Fei1 9dd7d27737 hv: vlapic_timer: refine vlapic tscdeadline timer
Add vlapic_create_timer/vlapic_reset_timer to setup/reset a timer.
Add vlapic_update_lvtt to disarm timer when mode changes.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 18:03:33 +08:00
Li, Fei1 ea54216116 hv: vlapic_timer: add vlapic timer mode API
Add vlapic_lvtt_oneshot, vlapic_lvtt_masked
rename vlapic_periodic_timer to vlapic_lvtt_period
rename VLAPIC_TSCDEADLINE to vlapic_lvtt_tsc_deadline

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 18:03:33 +08:00
Li, Fei1 8ec78f8efc hv: vlapic: coding refine
Using __func__ instead of function string name.
Using tab instead of more whitespace.
Using macro instead of numeric constants.
Remove unnecessary function declaration.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 18:03:33 +08:00
Li, Fei1 b9971c206f hv: vlapic_timer: remove vlapic one-shot/periodic timer implement
These code is useless since it just pseudocode. Current it doesn't
support vlapic one-shot/periodic timer.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 18:03:33 +08:00
Li, Fei1 5df2efad4a hv: timer: make the timer list be ordered
make the timer list be ordered to speed up expried timer
process and next timer event finding.

Add timer would not schedule timer unless it's the next
timer event.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-05-15 18:03:33 +08:00
Geoffroy Van Cutsem 6fc5116776 Documentation: update the contributing guide to use new LICENSE file
Update the "Contributing Guidelines" document to point at the
top-level LICENSE file that was created after the merger of
the three acrn-{hypervisor,devicemodel,documentation} repositories

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-05-15 18:03:33 +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
David B. Kinder b73f1face6 doc: add project README
Simplify the previous README and add more information about project
resources.

Fixes: #144

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 18:03:33 +08:00
David B. Kinder ec0d7e0e1e doc: update doc building howto
Post-merge, the doc building instructions need an update to reflect the
new diretory structure.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 18:03:33 +08:00
David Kinder 8ce423e211 Create LICENSE (#168)
* Create LICENSE

* Create LICENSE

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 18:03:33 +08:00
Rusty Lynch c874090b34 Fix typo in gitignore
Signed-off-by: Rusty Lynch <rusty.lynch@intel.com>
2018-05-15 18:03:33 +08:00
David B. Kinder f8861806f0 doc: post-merge changes to docs
Documentation updates were needed to account for changes caused by the
recent merging of the three acrn-hypervisor, acrn-devicemodel, and
acrn-documentation repos.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 18:03:33 +08:00
Geoffroy Van Cutsem 12fb4b0584 doc: Adjust various scripts accordingly
Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 18:02:07 +08:00
Jack Ren 60c07fba51 add .gitignore
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-05-15 17:41:53 +08:00
Zide Chen 6f97a14398 HV: Enable CR0.WP
Page fault could be raised if writing to read-only pages. This is
useful for debugging.

Signed-off-by: Zide Chen <zide.chen@intel.com>
2018-05-15 17:25:59 +08:00
Victor Sun c53a04f56c HV: 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:59 +08:00
lijinxia 3b6fe5782d Revert "HV: Prepare cpu_secondary.S for AP trampoline code relocation"
This reverts commit bfa67fa6a0.
2018-05-15 17:25:59 +08:00
lijinxia b3dd135ed3 Revert "HV: added memory allocation functions for AP trampoline code relocation"
This reverts commit 41b83bb20b.
2018-05-15 17:25:58 +08:00
lijinxia f8fbdbe7ec Revert "HV: Make AP trampoline code relocatable"
This reverts commit 31bf2befbf.
2018-05-15 17:25:58 +08:00
lijinxia 0c5956beb1 Revert "HV: adjust the base address of guest initial page tables"
This reverts commit 4aab1ea80d.
2018-05-15 17:25:58 +08:00
Zide Chen 6de5b0478c HV: adjust the base address of guest initial page tables
V2->V3: Updated variable name: trampoline_code_paddr
V1->V2: changed variable name: init_ap_code_addr

These page tablea are sitting right after the trampoline code, so adjust it according to
the actual loaded address for trampoline code

Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2018-05-15 17:25:58 +08:00
Zide Chen fe6397d9d8 HV: Make AP trampoline code relocatable
V3->V4: Updated function/variable names for accurancy
V2->V3: Changed a few function/variable names to make it less confusing
V1->V2: removed the unneccesary cache flushing

- For UEFI boot, allocate memory for trampoline code in ACRN EFI,
  and pass the pointer to HV through efi_ctx
- For other boot, scan E820 to allocate memory in HV run time
- update_trampoline_code_refs() updates all the references that need the
  absolute PA with the actual load address

Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2018-05-15 17:25:58 +08:00
Zide Chen ceb3076b69 HV: added memory allocation functions for AP trampoline code relocation
V2->V3: Fixed the booting issue on MRB board and removed the restriction
        of allocate memory from address 0

1) Fix the booting from MRB issue
-#define    CONFIG_LOW_RAM_SIZE 0x000CF000
+#define    CONFIG_LOW_RAM_SIZE 0x00010000

2) changed e820_alloc_low_memory() to handle corner case of unaligned e820 entries
  and enable it to allocate memory at address 0
+		a length = end > start ? (end - start) : 0;

-       /* We don't want the first page */
-       if ((length == size) && (start == 0))
-           continue;

3) changed emalloc_for_low_mem() to enable to allocate memory at address 0
-       /* We don't want the first page */
-       if (start == 0)
-           start = EFI_PAGE_SIZE;

V1->V2: moved e820_alloc_low_memory() to guest.c and added the logic to
        handle unaligned E820 entries

emalloc_for_low_mem() is used if CONFIG_EFI_STUB is defined.
e820_alloc_low_memory() is used for other cases

In either case, the allocated memory will be marked with E820_TYPE_RESERVED

Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2018-05-15 17:25:58 +08:00
Zide Chen 9323f811ea HV: Prepare cpu_secondary.S for AP trampoline code relocation
V1->V2: removed CONFIG_LOW_RAM_START and added ".org 0" to
cpu_secondary.S

The assumption is trampoline code is relocated while HV is not, so:

trampoline code is built at address 0, and CS register is updated
by SIPI to reflect the correct vector

in real mode part, added extra pointers for page tables and long jump buffer
so it's possible for HV code to patch the relocation offset

in long mode part, use absolute addressing when referring HV symbols,
and use relative addressing for symbols within trampoline code

Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2018-05-15 17:25:58 +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
Zide Chen eebf5fec6f HV: correct the handling of MU_MEM_ATTR_READ MMU flag
Currently config_page_table_attr() treats MMU_MEM_ATTR_READ exactly as
MMU_MEM_ATTR_BIT_READ_WRITE for PTT_HOST, so even when MMU_MEM_ATTR_WRITE
is not used, the R/W bit in PTE is still being set

Signed-off-by: Zide Chen <zide.chen@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
David B. Kinder 8a73718af3 doc: add use of GitHub issues
We've enabled GitHub issues for submitting and tracking bug and
enhancement requests for the project.  Add some documentation about how
to use issues and what to expect.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 17:25:58 +08:00
Zide Chen 260b37a52f HV: Fix the missing list_head initializaiton
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@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
Yonghua Huang e8d5a497f3 refine external interrupt VM exit handler
- According to Intel SDM 24.9.2,Vol3, should check the
  validity of "VM-exit interruption information" before
  extracting the vector of interrupt.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-15 17:25:58 +08:00
Yonghua Huang 121d14a616 rename 'req_buf' field in 'struct vm_sw_info'
- rename it to 'io_shared_page' to keep consistent
   with ACRN HDL foils.

 - update related code that reference this data structure.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2018-05-15 17:25:58 +08:00
Geoffroy Van Cutsem bf0d79b69d Make the Service OS bootloader configurable
This patch makes the Service OS bootloader configurable by passing
a command-line argument to 'acrn.efi' when setting up the EFI
bootloader using, e.g., 'efibootmgr'. If no argument is passed, the
default bootloader used is: "\EFI\org.clearlinux\bootloaderx64.efi".
This is the default bootloader/setting used by Clearlinux and is set
in the bsp/uefi/include/bsp/bsp_cfg.h file (via the
CONFIG_UEFI_OS_LOADER_NAME define)

The general format of the argument is: "bootloader=<\path\to\bootloader>".

As a concrete example, imagine the following set-up:
* You have installed the Service OS (bare-metal for now)
* Bootloader is "\EFI\org.clearlinux\bootloaderx64.efi"
* Boot device is '/dev/sda'
* EFI System Partition (ESP) is '1'
* You put the ACRN hypervisor under "\EFI\acrn\"
To change the default boot entry to boot the ACRN hypervisor, enter:
   # efibootmgr -c -l "\EFI\acrn\acrn.efi" -d /dev/sda -p 1 \
      -L "ACRN Hypervisor" -u "bootloader=\EFI\org.clearlinux\bootloaderx64.efi"
And reboot your machine.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-05-15 17:25:58 +08:00
David B. Kinder 7dd647672c doc: GSG formating fix, RTD theme tweak
Fix some formatting problems with a recent GSG update.  Tweak the
custom CSS to adjust code block (and code literal) colors.  Update
Makefile to document doc build options for pulling source from the other
repos and for publishing targets.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-15 17:25:58 +08:00