Commit Graph

3030 Commits

Author SHA1 Message Date
Victor Sun d0eb83aa0c HV: move Kconfig IOREQ_POLLING to acrn vm config
Previously I/O emulation completion mode mode was configured in Kconfig:

	config IOREQ_NOTIFICATION
	       bool "Notification mode"
	       help
	         When I/O request is completed, SOS will mark the completion status and
	         notify hypervisor via hypercall. Hypervisor will finish the post work
	         when notification is received.

	config IOREQ_POLLING
	       bool "Polling mode"
	       help
	         When I/O request is completed, SOS will only mark completion status
	         without notifying hypervisor. Hypervisor will poll the completion
	         status and finish the post work.

Now move this configuration to guest_flags of acrn_vm_config struct.

	if ((vm_config->guest_flags & IO_COMPLETION_POLLING) != 0U) {
		I/O with polling;
	} else {
		I/O with notification;
	}

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-25 10:24:18 +08:00
Tw 6584b5476e Makefile: add missing dependency
There is a missing dependency between lib and bin in Makefile.
BTW, this issue is triggered by concurrent build.

Tracked-On: #2370
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-25 08:46:31 +08:00
David B. Kinder c43bca9c86 doc: add a FAQ doc
Start a new FAQ document with questions we're often being asked on
support channels.  We'll expand this list over time, and as the number
of questions grow, we'll organize them as appropriate.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-01-23 22:29:56 -08:00
David B. Kinder bb8f539017 doc: add AGL as VMs on ACRN doc
Add a tutorial explaining how to set up a demo using AGL as UOSes as
used in a CES automotive demo.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-01-23 22:28:57 -08:00
Chaohong guo 5c5f43523a HV: modify RELOC kconfig option default to "enable"
re-enable RELOC kconfig as default to "y".

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
2019-01-24 11:59:21 +08:00
Chaohong guo 8f22a6e89a HV: fix per-cpu stack relocation in trampoline.c
In write_trampoline_stack_sym(), when do relocation for pcpu's stack,
it wrongly adds an offset. As a result, during booting, when non-BSP
CPU (APs) tries to run trampoline code once they are waken up by BSP
via SIPI, system hangs.

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Reviewed-By: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
2019-01-24 11:59:21 +08:00
Chaohong guo 41dd38baf2 HV: init_paging() wrongly calcuate the size of hypervisor
when relocation is enabled, the calcuation of HV size in init_paging
routine is not right. As a result, it doesn't enable NX bit for many
pages which don't belong to hypervisor text section.

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
2019-01-24 11:59:21 +08:00
Chaohong guo 9feab4cf29 HV: adjust the starting addr of HV to be 2M-aligned
In init_paging(), when modify page table, it does a round up to 2M on
the starting address of HV memory. If the address is not 2M aligned,
memory overwrite occurs, or memory attribute(cache, u/s) may be not
right. Besides, trusty memory (uos_sworld_memory) in .bss section is 2M
aligned during compiling,  after enabling HV memroy 2M alignment, when
relocation is enabled, EFI stub or other loaders just needs to find a
2M-aligned starting addr for HV memory.

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
2019-01-24 11:59:21 +08:00
Chaohong guo 07f14401ec HV: save efi_ctx into HV to use after init_paging()
efi_ctx is passed by EFI stub to hypervisor. The memory was allocated
right after HV binary and marked as Efireserved. But HV is doing a 2MB
alignment in init_paging() and might overwrite the efi_ctx struct or
change the page table attribute. Now, EFI STUB uses Efiloaderdata type
memory and the memory can be re-use by hypervisor/sos after boot time
done. HV should save itself a copy if the content is still needed after
init_paging().

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Reviewed-by: Zheng, Gen <gen.zheng@intel.com>
2019-01-24 11:59:21 +08:00
Chaohong guo a445a4eae0 EFI: Allocate EFI boot related struct from EFI allocation pool
Current EFI boot related structs are allocated right after HV binary, and
marked as EfiResered. In fact, the memory should be reclaimed and
managed by HV once EFI boot is done, Moreover, HV is doing 2M alignment,
which is overwriting this allocated memory. This patch is to allocate EFI
info from EFI allocation pool and marked as EFiloaderdata, so that the
memory is used by HV, also, it will reduce the fragmentation.

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Zheng, Gen <gen.zheng@intel.com>
2019-01-24 11:59:21 +08:00
Chaohong guo ad0f8bc3b1 EFI: Allocate 2M aligned memory for hypervisor image
Hypervisor does memory alignment during initializing paging(init_paging)
although the starting address allocated by EFI stub doesn't meet the
requirement. As a result, HV might overwrite some memory belong to UEFI
BIOS. The patch introduces a new routine to fix the issue.

Tracked-On: #2349
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Reviewed-by: Zheng, Gen <gen.zheng@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
2019-01-24 11:59:21 +08:00
Ross Burton 912be6c4dd tools: respect CFLAGS and LDFLAGS from environment
The build environment might want to pass extra CFLAGS or LDFLAGS to the build of
the acrn tools. With conventional build systems like automake, Meson, etc this
is possible by just setting CFLAGS and LDFLAGS in the environment.

However as the tools are built using bare Makefiles, these environment variables
are overwritten.  Respect them by renaming the variables in the Makefiles to
e.g. LOG_CFLAGS and adding CFLAGS to that.

Tracked-On: #2316
Signed-off-by: Ross Burton <ross.burton@intel.com>
2019-01-24 09:33:00 +08:00
Mingqiang Chi 899c914606 hv:Fix MISRA-C violations in vm.h
-- fix "Macro parameter not in brackets" for PLUG_CPU(n)
-- fix "Array has no bounds specified" for vm_configs[]

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2019-01-24 08:23:49 +08:00
Ross Burton 5ba4afcffe Use $(MAKE) when recursing
Using 'make' directly means that the jobserver environment variables don't get
passed down, so sub-builds for example don't use -j.

This is documented as the wrong thing to do:
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html#MAKE-Variable

Use $(MAKE) instead, and compile times drastically improve:

  acrn-devicemodel    do_compile   -13.5s   -89.6%      15.0s -> 1.6s

Tracked-On: #2370
Signed-off-by: Ross Burton <ross.burton@intel.com>
2019-01-24 08:22:32 +08:00
Shiqing Gao d0c9fce72d doc: add more rules in coding guidelines
This patch adds more rules in coding guidelines.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-01-23 11:57:10 -08:00
Jason Chen CJ 3c60512738 io_emul: reorg function definition to pass partition mode build
reorg function definition to pass partition mode build

Tracked-On: #2394
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-01-23 16:21:17 +08:00
Jason Chen CJ 15030f6f2c io_emul: reshuffle io emulation path
This is the following patch after removing pending_pre_work, it make sure
all io emulation is done on its own cpu.

For hv emulated request, it follows the steps:
	hv_emulate_pio->emulate_pio_complete
	hv_emulate_mmio->emulate_mmio_complete

For dm emulated request, it follows the steps:
	acrn_insert_request->dm_emulate_io_complete
while in acrn_insert_request, it could trigger scheduling out then resume by
hcall_notify_ioreq_finish, or busy wait for ioreq completion if polling mode
is enabled.

Tracked-On: #2394
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2019-01-23 16:21:17 +08:00
Jason Chen CJ fb41ea5cfb io_emul: remove pending_pre_work
Now we do not need pending_pre_work anymore, as we can make sure IO request
VCPU resume from where it paused.

Now only three fixed points will try to do schedule:
- vcpu_thread: before vm entry, will check reschedule flag and to it if needed
- default_idle: loop check reschedule flag to see if need switch out
- io request: if IO REQ need DM's handle, it will schedule out

Tracked-On: #2394
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2019-01-23 16:21:17 +08:00
Jason Chen CJ 4fc54f952e schedule: add full context switch support
this patch added full context switch support for scheduling, it make sure
each VCPU has its own stack, and added host_sp field in struct sched_object
to record host stack pointer for each switch out object.

Arch related function arch_switch_to is added for context switch.

To benefit debugging, a name[] field is also added into struct sched_object.

Tracked-On: #2394
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2019-01-23 16:21:17 +08:00
Jason Chen CJ 21092e6f6d schedule: use per_cpu idle object
To support full context switch scheduling, each physical
CPU must have its own idle sched_obj.

Tracked-On: #2394
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
2019-01-23 16:21:17 +08:00
Shiqing Gao 5e94788689 hv: vlapic: remove `calcvdest`
- remove `calcvdest` and use `vlapic_calcdest` directly

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-23 13:43:09 +08:00
Junjie Mao fd3279204e kconfig: update .config on missed or conflicting symbol values
The existing .config may have missed or conflicting values if the file is
manually edited or Kconfig is changed. Kconfiglib will assign default values to
missed symbols and resolve conflicts when loading .config, but the current
silentoldconfig.py fails to write the updated symbol values back to .config.

This patch checks if any missed or conflicting symbol value is fixed by
Kconfiglib and write the updated values back to .config if necessary.

Tracked-On: #2371
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
2019-01-23 13:02:39 +08:00
Conghui Chen ca925f0dd4 dm: storage: change DISCARD to synchronous mode
For virtio-blk, when the backend is a regular file, the discard
and
is implemented by fallocate(), but this function will not wait for
the discard command handled by disk.
So, add fdatasync to make sure the DISCARD is executed
synchronously.

Tracked-On: #2395
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Wang Yu <yu1.wang@intel.com>
2019-01-23 12:56:47 +08:00
Peter Fang 4642269248 dm: vhpet: add vHPET support
vHPET is used as a source of system timer by UEFI (e.g. OVMF).

This provides an alternative to using vPIT, which OVMF assumes is always
connected to vPIC.

This is ported from Bhyve, with a few changes:

- move to user space, using acrn_timer
- enable timers only when necessary

Origin: FreeBSD
License: BSD-3-Clause
URL: https://svnweb.freebsd.org/
commit: 326257
Purpose: Adding vHPET support.
Maintained-by: External

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang 0343da8c70 dm: vhpet: add HPET-related header files
Add the necessary header files for vHPET.

Origin: FreeBSD
License: BSD-3-Clause
URL: https://svnweb.freebsd.org/
commit: 326257
Purpose: Adding vHPET support.
Maintained-by: External

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang 3fe4c3f2a8 dm: provide timer callback handlers the number of expirations
It is possible for multiple timeouts to occur in one mevent epoll
iteration. Providing the number of timer expirations to the timer
callback handlers can be useful. E.g., this could improve emulation of
timing-sensitive hardware components.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang 0f7535fdbe dm: add absolute timer mode
Allow specifying the initial expiration in absolute time.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Peter Fang d1e1aa3077 dm: create mevent's pipe in non-blocking mode
It was designed to be used in non-blocking mode to prevent the mevent
thread from blocking itself indefinitely, but it was created in
blocking mode.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-23 10:33:28 +08:00
Shiqing Gao a9709bf857 hv: Makefile: add the dependency of $(LIB_FLAGS)
This patch adds the dependency of $(LIB_FLAGS) when building .out file.
So that the target is updated whenever there is a update in
debug/release library.

Tracked-On: #2389
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-23 08:27:39 +08:00
Shiqing Gao b489aec3e1 hv: idt: separate the MACRO definition
For binutils <= 2.26:
'U' suffix for unsigned constant is not accepted by binutils assembler.

This patch separates the MACRO definition for ASSEMBLER
and non-ASSEMBLER code in idt.h

Tracked-On: #2200
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-01-23 08:23:48 +08:00
Tw 862ed16ed7 Makefile: add rules for installing debug information
Add rules for installing debug information.

Tracked-On: #2344
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-22 15:00:37 +08:00
Minggui Cao 173b534b05 HV: modularization cleanup instr_emul header file
separate the private macro/structure/functions, which are just used
in instr_emul.c;

and move instr_emul.h to public include path.

Tracked-On: #1842
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-22 10:50:30 +08:00
Victor Sun 18dbdfd5d7 HV: replace lapic_pt with guest flag in vm_config
The member of lapic_pt in acrn_vm_config will be replaced by
guest_flag of LAPIC_PASSTHROUGH;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun 68aa718ca0 HV: replace bootargs config with acrn_vm_os_config
The member of bootargs in acrn_vm_config will be replaced by
acrn_vm_os_config struct.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun 23f8e5e598 HV: replace memory config with acrn_vm_mem_config
The member of mem_size and start_hpa in acrn_vm_config struct will
be replaced with the acrn_vm_mem_config struct;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun 253b25937b HV: remove vm_config pointer in acrn_vm struct
For each vm_array[] item, its config is located in corresponding
index of vm_configs[], so vm_config pointer is not needed any more.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun 7bf9b1be2c HV: enable pcpu bitmap config for partition mode
All the legacy cpu configration in vm_description.c are all cleaned up;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun bc62ab79c2 HV: remove unused vm num config
The VM number configuration in description.c is never used, remove it;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun 2e32fba536 HV: remove sworld_supported in acrn_vm_config
We will use guest_flags of SECURE_WORLD_ENABLED to check wthether
sworld is supported.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun ec199d9609 HV: add get_sos_vm api
This patch creates a new get_sos_vm() api to replace get_vm_from_vmid(0U)
because VM 0 might not be SOS VM now;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun f3014a3c89 HV: show correct vm name per config
The patch will show correct VM name per its configuration. As we do not
validate vm id when call get_vm_from_vmid() any more, we only show VM's
states which their VM type are defined;

If VM name is not configured in config file, then the name is specified
with vm id, i.e. "ACRN VM_(vm id)"

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun e6117e0d5b HV: refine launch vm interface
When pcpu enter guest mode, it will call launch_vms() function to launch
VMs in global vm_configs array.

In launch_vms() function, current pcpu will go through vm_config array list
and check whether it is a bsp of configured VM, if yes then it will prepare
corresponding VM and start it. The index of vm_config array will be specified
to VM id.

The first least significant bit in pcpu_bitmap means the bsp of the VM.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Victor Sun 49e6deaf26 HV: rename the term of vm0 to sos vm
Under sharing mode, VM0 is identical with SOS VM. But the coupling of
SOS VM and VM 0 is not friendly for partition mode.

This patch is a pure term change of vm0 to sos VM, it does not change
any code logic or senmantic.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 18:03:31 +08:00
Mingqiang Chi 55e5ed2e1a hv:move ept violation handler to io_emul.c
move this api from ept.c to io_emul.c to avoid
reverse dependency.

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 13:49:54 +08:00
Mingqiang Chi 1d98b7012d hv: move 'setup_io_bitmap' to vm.c
move this api from io_emul.c to vm.c to avoid reverse
dependency

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-01-21 13:49:54 +08:00
Mingqiang Chi de4ab6fdfa hv:modulization for IO Emulation
-- rename io.c to io_emul.c, add io_emul.h
-- rename io_request.c to io_req.c,rename ioreq.h to io_req.h
-- move some APIs declaration from ioreq.h to io_emul.h
   related IO emulation

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
	modified:   ../doc/acrn.doxyfile
	modified:   Makefile
	renamed:    arch/x86/io.c -> arch/x86/io_emul.c
	renamed:    common/io_request.c -> common/io_req.c
	modified:   include/arch/x86/hv_arch.h
	modified:   include/arch/x86/io.h
	new file:   include/arch/x86/io_emul.h
	renamed:    include/arch/x86/ioreq.h -> include/arch/x86/io_req.h
2019-01-21 13:49:54 +08:00
Minggui Cao 808d0af2c8 HV: check to avoid interrupt delay timer add twice
to edge interrupt, like eth device, it can triger the interrupt again
when its IRQ in softirq entry queue or in timer list.

in current design, for sofrirq entry, it calls "list_del" before
"list_add_tail", to avoid the entry added twice.

so for interrupt delay timer, add to check if it is started
then just drop the next one; to avoid it enqueue twice.

Tracked-On: #2365
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
2019-01-21 11:18:08 +08:00
Victor Sun d9c38bafa5 HV: remove unused mptable info
mptable pointer in acrn_vm_config struct and also extern struct mptable_vm1/2
declared in mptable.h are not used any more, remove them.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-18 11:50:00 +08:00
Victor Sun a8e4f227ba HV: add new acrn_vm_config member and config files
- add new struct member for acrn_vm_config;

- add sharing_config.c file with initialized vm_config array;

- add SOS VM config header for apl-mrb/apl-nuc/up2 and dnv-cb2 board;

- and partition_config.c file with dummy vm_config array;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-18 11:50:00 +08:00
Victor Sun c4a230f313 HV: rename the term of vm_description to vm_config
This patch is a pure term change of vm_description to vm_config,
the struct name of vm_description is changed to acrn_vm_config.

The patch does not change any code logic or senmantic.

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-18 11:50:00 +08:00