Commit Graph

1659 Commits

Author SHA1 Message Date
Qi Yadong 8f0cb5630d HV: trusty: refine version checking when initializing trusty
Replace if--else logic with switch--case when checking interface
version.

Tracked-On: #1265
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Acked-by: Zhu Bing <bing.zhu@intel.com>
2018-09-18 13:09:01 +08:00
Shiqing Gao 9d602208e5 hv: remove unused MACROs
MISRA-C states that redundant macros reduce the maintainability of code.

In some cases, we would like to keep the current unused macros for code
completeness, such as cpu registers. These macros might be used later.

This patch removes some unused macros that is not critical for code
completeness.

v1 -> v2:
 * Keep TRUSTY_VERSION in trusty.c.
   Yadong will cook another patch which will utilize TRUSTY_VERSION.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-18 09:43:43 +08:00
Xiangyang Wu bb0a2bc2ab HV:Hypercall:Remove redundant error checking
In the current hypervisor hypercall, first all vcpu is
allocated to SOS, vcpu's vm field is initialized to vm0.
When the vcpu is offlined, vcpu will be paused and vcpu's
vm field is set as NULL by DM. When UOS is created, vcpu's
vm field is set as UOS's vm. So when vmcall_vmexit_handler
is invoked, vcpu's vm filed is always non-NULL.
error checking for vm pointer is done in the function
"vmcall_vmexit_handler", vmcall_vmexit_handler will
guarantee that vm is vm0.

So all hypercall functions (these functions is just for handler
hypercall, except vmcall_vmexit_handler) don't need to check
whether invoking vm is NULL and don't need to check whether
invoking vm is vm0 or not.

Remove related invoking vm error checking for hypercall handling.

V1 --> V2:
	Add pre-condition for hypercall in the head file.
V2 --> V3:
	Add pre-condition for copy_from_gpa and copy_to_gpa.
V3 --> V4:
	Add pre-condition both in the head file and source file.

Tracked-On:#1258

Signed-off-by: Xiangyang Wu <xiangyang.wu@linux.intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-18 09:43:24 +08:00
Sainath Grandhi d8508e4229 hv: init_iommu rework to enable IOMMU for partition mode ACRN
Current code enables IOMMU from init_iommu_vm0_domain which is called
from vm0/sos boot sequence. For partition mode VMs, this is not called as
VMs are numbered from 1.

This patch adds support to initialize root table pointer for each IOMMU
and enable all IOMMUs from init_iommu. Hence IOMMUs are enabled even
though ACRN does not boot vm0.

Tracked-On: #1246
Signed-off-by: Sainath Grandhi sainath.grandhi@intel.com
2018-09-18 09:21:31 +08:00
Yonghua Huang 2af08d9619 HV: refine 'struct lapic_regs' definition.
- remove 'PAD3' & 'PAD4'
 - define local APIC registers by 'struct lapic_reg' type.

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-18 09:09:44 +08:00
Binbin Wu 5329ced1ea hv: vtd: fix potential buffer overflow in suspend/resume
In current code of suspend_iommu/resume_iommu, there is potential buffer overflow
according to the code.
This patch put the buffer to struct dmar_drhd_rt, so that no need to access the buffer
via index.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Tracked-On: #1252
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-18 09:09:18 +08:00
Zhang, wenling f355cdf6f4 Revert "DM USB: xHCI: enable USB xHCI emulation in LaaG and AaaG."
This reverts commit c03ea2d365.
2018-09-17 15:13:05 +08:00
Junjun Shan 83d1ddc6d8 hv:Delete the dead code
Delete the dead code get_irq_info(), local_get_irq_info() in io_request.c
and definition in guest.h.

v1->v2
 *the dead code used pointers which not checked before use, therefore it
  causes "pointer not checked for null before use". To make it clearly,
  modify the subject to "delete the dead code" directly.

 *remove dead code local_get_irq_info() in io_request.c and definition
  in guest.h together.

Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 09:52:02 +08:00
Yin Fengwei c307e1b6eb hv: long and long long is same for printf within x86_64
In ACRN hypervisor, u/int64_t is defined as unsigned/ long.
It's nature to use %l to print it. But current printf use
%l to print int and only use %ll for long.

This patch fix it by treat long and long long same for printf.

Tracked-On: #1230
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-17 09:50:06 +08:00
David B. Kinder a47f5d4129 doc: fix Makefile to address multiple publishers
Need to make sure the local projectacrn.github.io is in sync with the
master before starting up the publishing process.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-09-16 14:30:05 -07:00
David B. Kinder 41a171444b doc: fix spaces in release notes
Removed white space at the end of the line, and fixed a sentence that
did not have a space after the period.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-09-16 14:29:48 -07:00
Xie, nanlin 3c8157bf22 doc: Add new feature in v0.2 release note
Add new feature list and description in v0.2 release note.

Signed-off-by: Xie, nanlin <nanlin.xie@intel.com>
2018-09-16 13:58:37 -07:00
Xiaoguang Wu c03ea2d365 DM USB: xHCI: enable USB xHCI emulation in LaaG and AaaG.
Change launch_uos.sh to enable USB xHCI full emulation support.

Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Tracked-On: #1242
2018-09-14 13:32:34 +08:00
Xiaoguang Wu b4755cdc52 DM USB: xHCI: enable 'cold plug' mode
USB device is connected before UOS is booted up, this scenario is
called 'cold plug' for easy to refer.

Under 'cold plug' situation, the libusb will not report 'connect'
event to device model, hence UOS will not discover 'cold plugged'
device.

This patch add support to fix this issue.

Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Tracked-On: #1242
2018-09-14 13:32:34 +08:00
Liang Yang 612037e138 DM USB: xHCI: enable Flat Mode Hub emulation support.
Flat Mode for hub emulation means DM emulates USB devices under hub but
hide hub itself. Under this design the Guest OS cannot see any emulated
hub. So in the perspective of Guest OS, all the emulated devices are
under root hub.

This patch is used to enable feature as mentioned above. And please NOTE,
it is the initial version of hub flat Mode hub emulation, there are one
limitation: only one physical hub is supported. If second physical hub is
connected, the connect and disconnect behavior in second hub may affect
the function of first emulated hub.

The USB HUB device model should be the final long term solution, but it is
very complex. Use flat mode HUB emulation as the short term solution first
to support some USB touch devices which integrated internal HUB.

Signed-off-by: Liang Yang <liang3.yang@intel.com>
Reviewed-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
Tracked-On: #1243
2018-09-14 13:32:34 +08:00
Shiqing Gao d886375ee4 hv: clean up spinlock
- move spinlock_init and spinlock_obtain to spinlock.h as inline APIs
- remove spinlock.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-09-14 09:44:44 +08:00
Qi Yadong 8858634493 HV: update opcode when decode_two_byte_opcode()
The vie->opcode should be updated when decode_two_byte_opcode(),
otherwise for two bytes opcode emulate(movzx/movsx) will fail.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
2018-09-14 09:26:48 +08:00
Shiqing Gao 5023937041 hv: merge pgtable_types.h and pgtable.h
- move the contents in pgtable_types.h to pgtable.h
- remove pgtable_types.h

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-13 16:17:48 +08:00
Shiqing Gao 83e7995d5d hv: clean up some header files
- move the contents in macros.h and stdarg.h to util.h
- remove macros.h and stdarg.h

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-13 13:11:57 +08:00
Yan, Like 5a996ce6a9 hv:irq: correct the size of irq_alloc_bitmap
This commit corrected the size of irq_alloc_bitmap[].

Tracked-On: #1229
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-09-13 13:11:31 +08:00
Junjun Shan 4fd5102edc hv:treewide:fix multiple MISRAC violations
MISRAC has requirements about literal value requires a U suffix and
signed/unsigned conversion with cast. This patch is used to solve
these violations.

v1->v2
 *Drop the cast of sz from uint32_t to int32_t, the signed/unsigned
  violation of nchars will be solved by other patch together with
  printf/sprintf/console/vuart/uart code.

 *Delete the unnecessary L suffix of shifting operand.

Tracked-On: #861
Signed-off-by: Junjun Shan <junjun.shan@intel.com>
Reviewed by: Junjie Mao <junjie.mao@intel.com>
2018-09-13 11:12:29 +08:00
Jason Chen CJ 00edd838c9 hypercall: no need check HV memory overlap for MR_DEL
in local_set_vm_memory_region, hpa is not used for MR_DEL, and it does
not need check HV memory overlap for a MR_DEL operation.

this is a bug exposed by remapping SOS first page, as the remap page whose
gpa = 0 actually fall into HV memory area; while during MR_DEL, the input
param vm0_gpa is set to 0 by default.

Tracked-On: #1124
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-09-13 10:10:22 +08:00
Liu, Xinwu 876cc68311 tools:acrn-crashlog: Change the algorithm of generating event key
Acrnprobe is using SHA to generate ids for events. These ids are only used
to index events, not for cryptographic purpose.

This patch unify the generating algorithm of short and long ids to
SHA256.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-09-13 10:03:23 +08:00
Shiqing Gao b1ba12ae1b hv: clean up spinlock wrappers
- remove the following unnecessary spinlock wrappers
  #define IOMMU_LOCK(u) spinlock_obtain(&((u)->lock))
  #define IOMMU_UNLOCK(u) spinlock_release(&((u)->lock))
- remove the unnecessary comments in vpic.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-13 09:28:20 +08:00
Yin Fengwei 44a2d77c32 hv: add SMAP/SMEP check during guest page walking
According to SDM 4.6 Access Rights definition, if SMAP/SMEP
is enabled, more conditions are used to decide the access rights
like SMAP/SMEP, EFLAGS.AC, R/W bit in every paging-structure entry
for page walking.

This patch add the check to guest page walking function and inject
page fault accordingly.

Tracked-On: #1207
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-09-13 09:21:59 +08:00
Yin Fengwei d958d31e1b hv: fix the issue of movs emulation
The current movs emulation has issues:
1. it use gva to get/put data.
2. it only support src and dst operand are memory which does not
   apply to our case (one of them should be mmio and triggers
   EPT voilation).

This patch fix the issue by:
1. convert the address from gva to hva before access it.
2. handle mmio emulation.

Also fix the issue introduced by previous instruction reshuffle
patchset:
1. the desc validation should be only applied to none-64bit mode.
2. gva2gpa should be given correct guest virtual address.

Specailly for movs, we cache the dst gpa if the check during
movs decoding success. And use it directly during movs
emulation.

Tracked-On: #1207
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Tested-by: Qi Yadong <yadog.qi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-09-13 09:21:59 +08:00
Shiqing Gao d84f7a4fd5 hv: clean up udelay/mdelay related code
- replace the usage of mdelay with udelay
- remove lib/mdelay.c
- rename udelay.c to misc.c
  future other small APIs could put in misc.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 16:08:49 +08:00
Shiqing Gao 7cab77dace hv: clean up div related code
- replace udiv64 with direct integer divide
- remove lib/div.c

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 16:08:49 +08:00
Shiqing Gao 1d2ed1adee hv: vioapic/vpic: clean up spinlock wrappers
remove the following unnecessary spinlock wrappers

 #define VIOAPIC_LOCK(vioapic)   spinlock_obtain(&((vioapic)->mtx))
 #define VIOAPIC_UNLOCK(vioapic)  spinlock_release(&((vioapic)->mtx))

 #define    VPIC_LOCK_INIT(vpic)    spinlock_init(&((vpic)->lock))
 #define    VPIC_LOCK(vpic)         spinlock_obtain(&((vpic)->lock))
 #define    VPIC_UNLOCK(vpic)       spinlock_release(&((vpic)->lock))

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 14:41:16 +08:00
Binbin Wu 4f20c44ec3 dm: passthru: fix a bug in msix read/write
In current code, when read/write msix table, it first handle the case
the offset is in pba range when msix talbe and pba share the same bar.
But the code didn't add the condition whether pba bar equals msix table
bar. It will cause problems for the passthrugh devices,whose pba and msix
table don't share the same bar.

Tracked-On: #1209
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
2018-09-12 11:36:56 +08:00
Mingqiang Chi 60c05ace1a hv:Replace vlapic pointer with instance in vcpu_arch
-- update 'vlapic' in 'struct vcpu_arch' from pointer
   to instance
-- add inline function(vcpu_vlapic) in vcpu.h

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Mingqiang Chi f744762ad3 hv:Remove redundancy 'vlapic' in 'struct vcpu'
It has been defined in 'struct vcpu_arch'

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Mingqiang Chi aae5018bec hv:Move vlapic structure to vlapic.h
move structure vlapic_pir_desc/vlapic_timer/
acrn_vlapic from vlapic_priv.h to vlapic.h

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Mingqiang Chi fdb64095c4 hv:Replace dynamic memory allocation for apic access address
Replace pointer with static memory for apicv_apic_access_addr

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Mingqiang Chi 887ebf0b08 hv: Replace dynamic memory allocation for MSR bitmap
Replace pointer with static memory for msr_bitmap
inside structure vm_arch.

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Mingqiang Chi 02e7edc063 hv: Replace dynamic memory allocation for I/O bitmaps
-- Replace pointer with static memory for io_bitmap
  inside structure vm_arch.
-- Refine allow_guest_pio_access/deny_guest_pio_access

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Mingqiang Chi eada04b800 hv:Replace dynamic memory allocation for vmcs region
Replace vmcs pointer with static memory for vmcs region
inside structure vcpu_arch.

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-12 09:20:07 +08:00
Yuan Liu ca75d506b7 IOC mediator: add RTC feature
This patch implements RTC feature that UOS can set RTC wakeup timer
to IOC firmware with a specific time before enter S3/S5. IOC mediator
also needs to indicate RTC wakeup reason to UOS after exit S3/S5.

Tracked-On: #1213
Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-09-12 09:18:44 +08:00
David B. Kinder 42d9b24a54 doc: allow overriding displayed doc version
In special cases, we'd like to freeze doc versions based on a tag (e.g.,
tags/acrn-2018w34.4-140000p) and have that version show up on the
generated docs.  (Normally the version shown is from the
hypervisor/VERSION file.)

With this patch, if DOC_TAG=release then it uses a RELEASE=name
environment variable (e.g., from the make command line) to override the
displayed version:

    make DOC_TAG=release RELEASE=acrn-2018w34.4-140000p html
    make DOC_TAG=release RELEASE=acrn-2018w34.4-140000p publish

Assuming you've checked out the tagged branch (both for acrn-hypervisor
and acrn-kernel), these make commands will generate and publish docs to
https://projectacrn.github.io/acrn-2018w34.4-14000p

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-09-11 16:29:17 -07:00
Victor Sun dbcbe7d1ff HV: change wake vector to accommodate abl 1820HF1release
MRB bootloader is switched to ABL ver 1820HF1_release, so change platform
acpi info accordingly to support system S3.

Tracked-On: #1196

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-11 16:02:18 +08:00
Yin Fengwei bca43b5324 hv: avoid memory leak in trampoline code preparing
In function start_cpus, we allocated memory under 1M when
preparing AP trampoline code.

With S3 feature enabled, start_cpus is called every time after
ACRN resume from S3 which leaks the allocated memory for AP
trampoline code.

To avoid memory leak, move the AP trampoline preparing function
out of start_cpus to make sure the memory for AP trampoline is
only allocated one time when system boot.

Tracked-On: #1156
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Zide Chen <zide.chen@intel.com>
2018-09-11 13:00:54 +08:00
Xie, nanlin 9e76cf4800 doc: Add fixed issues in v0.2 release note
Filter v0.2 fixed issues from github closed issue list.

Signed-off-by: Nanlin Xie <nanlin.xie@intel.com>
2018-09-10 20:58:35 -07:00
Jian Jun Chen f1e87f60fc dm: vrtc: use signalfd to poll signal from timer
In the current implementation sigev_notify is configured as
SIGEV_THREAD. When timer expires an async thread is created and
the registered timer callback is called in the context of this
thread. vrtc_update_timer will access the global data vrtc. There
is a race condition that vrtc is freed when deinit and then a timer
expires. In this case vrtc_update_timer will access a freed buffer
which causes problem such as heap corruption and segment fault.

In this patch signal model is used when timer is created. The signal
is masked and a signalfd is used to poll on it with mevent. This avoids
the race condition.

Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Tracked-On: #1185
2018-09-11 10:50:16 +08:00
Shiqing Gao bcaede0c0e hv: treewide: fix 'Use of function like macro'
- convert function like macros to inline functions based on MISRA-C
  requirement
- remove some unused and duplicated macros

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
2018-09-11 10:49:48 +08:00
Jason Chen CJ d72e65c91a trusty: do not destroy secure world if it's not created
check sworld_eptp before real destroy_secure_world

Tracked-On: #1200
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-09-11 10:47:34 +08:00
Jason Chen CJ 8773dfb1f6 vlapic: unmap vlapic base only for SOS
as SOS mapped all memory at the beginning, so trap vlapic need unmap its
memory; for UOS, there is no need as UOS never mapped it.

Tracked-On: #1124
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-09-11 10:47:34 +08:00
Jason Chen CJ 457ac7408d vcpu: replace start_vcpu with run_vcpu
run_vcpu should be a more suitable name

Tracked-On: #1199
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-09-11 10:47:34 +08:00
Jason Chen CJ 2978c01f45 io: tiny fix for error message
error message for "read" or "write" was incorrect.
for developers, we just need print out direction & type value.

Tracked-On: #875
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-09-11 10:47:34 +08:00
Minggui Cao bfcf546180 Doc: add interrupt storm mitigation explanation.
Tracked-On: #866
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-09-11 09:01:06 +08:00
Victor Sun d8c4619ee9 HV: change wake vector info to accommodate abl
MRB bootloader is switched to ABL, so change platform acpi info accordingly
to support system S3.

Tracked-On: #1196

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-09-11 08:42:35 +08:00