Commit Graph

2327 Commits

Author SHA1 Message Date
Binbin Wu 32ed3d1a76 hv: vtd: move public API to the bottom part of the file
Move move public API to the bottom part of the file.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-20 13:30:13 +08:00
Binbin Wu efb249235a hv: vtd: merge lines for a statement if needed.
Becuase the number of character of a line is 120.
Merge lines for a statement if needed.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-20 13:30:13 +08:00
Binbin Wu e35a8e8cff hv: vtd: typo fix
dmar_uint -> dmar_unit
remove i in line 756 added by accident.

Tracked-On: #1855
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-20 13:30:13 +08:00
Shuo Liu 611944c018 dm: Fix race between ioreq client destroy and access
vcpu thread need to exit when doing VM full reset and VM shutdown.
Change the code to align the logic. This also can fix race condition
between ioreq client destruction and accessing.

Tracked-On: #1857
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-11-20 13:26:33 +08:00
Zide Chen 3b24c34cbf hv: msix: corrently determine when the guest is changing Message Data/Addr
The guest could write the MSI-X Table fields in DWORD or QWORD. For
example the Message Address could be a QWORD write or two DWORD writes,
the Message Data could be a DWORD write or part of a QWORD write that
is combined with the Vector Control. This patch captures all the
possible combinations when the guest is configuring the MSI-X Table.

Tracked-On: #1568
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
2018-11-20 12:59:09 +08:00
Zide Chen c41c0dab08 hv: properly initialize MSI-X table
Though guests are not supposed to read Message Data/Addr, it's still better
off to initialize them to 0.

vector_control should be initialize to zero besides the mask bit.

Tracked-On: #1568
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
2018-11-20 12:59:09 +08:00
Zide Chen 53971e1974 hv: fix 2 bugs in msix.c
- in vmsix_cfgwrite(), it should write the new value 'val'.
- in vmsix_table_mmio_access_handler(), mmio_gpa is a typo for intercepted_gpa.

Tracked-On: #1568
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
2018-11-20 12:59:09 +08:00
Shiqing Gao 119eccfea1 hv: hypercall: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in hypercall.c and vmcall.c

TO-DO:
Enhance Makefile to compile debug/release into 2 libraries

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-20 10:01:50 +08:00
Chen, Gang G fc9ec5d88f hv: Derive decryption key from Seed for Trusty to decrypt attestation keybox
CSE FW uses an AEK (Attestation keybox Encryption Key) to encrypt the keybox
with AES-256-GCM algorithm before sending it to Android/Trusty. This key is
derived from the latest platform Seed by CSE FW with KDF (key derivation function)
HMAC-SHA256. After Trusty retrieves this encrypted keybox over HECI/MEI driver,
Trusty needs the same AEKkey to decrypt it. Hence, before Trusty launches,
Hypervisor derives the same AEK key from Platform Seed with the same algorithm
and the same derivation parameters, then sends this AEK along with Trusty vSeed
to Trusty world memory.

Since Platform Seed is only visible to Hypervisor and it must not be
sent to any guest VM, only Hypervisor can derive this AEK from this
Platform Seed, just like previous per-Trusty virtual Seed derivation.
Please note that Android Attestation Keybox is shared in a single hardware
platform, so all the Trusty instance/world can get the same AEK for
decryption even if there are multiple Android User OS/VMs running
on top of Hypervisor.

v1 --> v2:
	Add detailed description why we need the patch to derive an extra key

v2 --> v3:
	Convert API descriptions to Doxygen

Tracked-On: #1812
Reviewed-by: Bing Zhu <bing.zhu@intel.com>
Reviewed-by: Kai Wang <kai.z.wang@intel.com>
Signed-off-by: Chen Gang G <gang.g.chen@intel.com>
Acked-by: Bing Zhu <bing.zhu@intel.com>
2018-11-20 09:22:37 +08:00
Ming Liu 7978188c1d tools: acrn-manager: set MAX_NAME_LEN to 32
I am currently using Yocto build and deploy UOS images, it would be
much more convenient to let the VMs to have the same names with when
they are being built. For instance, a typical image name in Yocto is
like: uos-image-weston, but it can not show the name completely with
'acrnctl list', since the length limit is 16.

Increasing the limit to 32 would fix this problem.

Tracked-On: #1837
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
2018-11-19 12:52:46 +08:00
Zide Chen 5d013ed2ba hv: vpci: revert the temporary workaround of handling I/O port CF9
Revert the temporary workaround of calling allow_guest_pio_access() to
reset the I/O bitmap for CF9.

For CONFIG_ADDR register, only intercept I/O port CF8 to achieve these:

- In SOS, I/O bitmap for port CF9 is not set.
- In UOS or in partition mode, I/O requests to CF9/CFA/CFB won't be handled
  by pci_cfgaddr_io_read/write() any more.

Tracked-On: #1815
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-19 09:34:34 +08:00
Zide Chen fe9a340ea9 hv: separate the PCI CONFIG_ADDR and CONFIG_DATA I/O port handlers
Register separate I/O emulation handlers for I/O port CF8 and CFC. This
makes the code simpler, and offers some flexibilities to be able to handle
CF8 and CFC ports differently.

Tracked-On: #1815
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-19 09:34:34 +08:00
Zide Chen 8b4f395683 hv: PIO emulation handler is attached to I/O port number only
An I/O handler is not linked to the I/O access size, so in searching for
the registered I/O handler, don't need to check the I/O request's access
size.

In struct vm_io_handler_desc, change fields addr and len to port_start and
port_end respectively to adapt to this change.

Tracked-On: #1815
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-19 09:34:34 +08:00
Jason Chen CJ 2c581751de vmx: tiny fix for MACRO name and print format
1. CPU_SEG_WRITE->CPU_SEG_READ: it's actually seg read
2. 0x%hu -> 0x%x: it need print hex format

Tracked-On: #1833
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-11-16 15:30:20 +08:00
Shiqing Gao 9c025190a9 hv: hv_main: clean up HV_DEBUG usage
- Remove the usage of HV_DEBUG in hv_main.c
The usage of HV_DEBUG in hv_main.c is for the shell command 'vmexit'.
Since vmexit info has been captured by acrntrace, there is no need to
keep this duplicated feature in shell command.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2018-11-16 14:47:24 +08:00
dongshen 1018a31cbb HV: For NUC, use 0x3F8/IRQ4 as the vuart port base address/IRQ and use ttyS0 accordingly
Tracked-On: #1817
Change-Id: I6f063e3f85b2050d63c75c1e8a46c5e8ab8a2860
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-11-16 10:24:48 +08:00
dongshen e56a6b588a HV: For MRB, use 0x3E8/IRQ6 as the vuart port base address/IRQ.
Tracked-On: #1817
Change-Id: Ib2e375a1e23eff1f1326728a023147db48fe4d5c
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-11-16 10:24:48 +08:00
dongshen 3b87e7c67f HV: Add vuart port base address/IRQ Kconfig options
Adding Kconfig option to define the vuart port base address/IRQ.
By default, use 0x3F8/IRQ4. For MRB, use 0x3E8/IRQ6.
We are experiencing problems on NUC after changing from 0x3F8/IRQ4
to 0x3E8/IRQ6.

Tracked-On: #1817
Change-Id: Ie407e51a7bc25ac0bb4c61453c969f1466fa33ca
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
2018-11-16 10:24:48 +08:00
Zheng, Gen b32e689a64 hypervisor: use "wbinvd" carefully in RT environment
Due to the side-effect to cache of "wbinvd" instruction, just apply it
in case of noncoherent DMA.

Tracked-On: #1824
Signed-off-by: Zheng, Gen <gen.zheng@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-11-16 10:24:23 +08:00
Shuo Liu 61e6c1f054 hv: reset VM ioreqs in reset_vm
ioreqs acrossing VM reset is meaningless. So we reset their status when
VM reset.
Please note, device model and service os need to handle various ioreqs
pending status in emergency reset condition carefully. Otherwises, the
post processing of such ioreqs might overwrite this reset.

Tracked-On: projectacrn#1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-16 09:14:26 +08:00
Yonghua Huang 2fa67a4471 HV: clear memory region used by UOS before it exit
this patch fixes such an information leaking issue:
in case that after a UOS is destroyed, its memroy
will be reclaimed and maybe re-allocated for a new UOS,
then the previous UOS sensitive data in memory may
be leaked to the new UOS.

Tracked-On: #1825
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-16 09:13:34 +08:00
Shuo Liu 8fa16211f6 hv: partition mode also needs free vm id when shutdown vm
Even in partition mode, we also need to clear vmid in vmid_bitmap to
indicate the VM is not present.

Tracked-On: projectacrn#1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-15 16:40:43 +08:00
zhonghua 9dacc4a57d tools:acrn-crashlog:fix potential issue
this patch fix potential issue of initialization
about local variable in fsutils.c

Tracked-On: #1024
Signed-off-by: Zhonghua <zhonghua.sun@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2018-11-15 16:39:54 +08:00
Shiqing Gao 6971cc832a hv: fix '(void) missing for discarded return value'
MISRA-C requires that the function call in which the returned
value is discarded shall be clearly indicated using (void).

This patch fixes the violations related to the following
function calls.
- instr_check_gva
- vlapic_set_local_intr
- prepare_vm
- enter_s3
- emulate_instruction
- ptdev_intx_pin_remap
- register_mmio_emulation_handler

v1 -> v2:
 * discard the return value of enter_s3

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2018-11-15 10:54:42 +08:00
Zide Chen a646fcf761 hv: fix 'No brackets to then/else' in vpci code
This patch addes missing brackets for 'if/else' statements based on
MISRA-C requirements 12 S.

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Reviewed-by: Huihuang Shi <huihuang.shi@intel.com>
2018-11-15 08:58:32 +08:00
Zide Chen bad813ea31 hv: fix MISRA-C violations in vpci code: Function pointer is of wrong type
576S: Function pointer is of wrong type. C90 requires the elements of an
designated initializer to appear in a fixed order, the same as the order of
declaration. C99 relaxes this rule but seems MISRA-C sticks to C90 in this
regard.

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Reviewed-by: Huihuang Shi <huihuang.shi@intel.com>
2018-11-15 08:58:32 +08:00
Zide Chen d3f0edfe4f hv: fix MISRA-C violations in vpci code: 93S, 331S and 612S
- 331S: Literal value requires a U suffix.
- 612S: inline function should be declared static.
- 93S: Value is not of appropriate type. MISRA-C imposes strict type
  checking: no comparison between signed and unsigned, etc.

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Huihuang Shi <huihuang.shi@intel.com>
2018-11-15 08:58:32 +08:00
Zide Chen f84f1a216b hv: fix MISRA-C violations in vpci code: implicit conversion
458S: Implicit conversion: actual to formal param (MR): "The value of an
actual parameter shall not be implicitly converted to the type of a formal
parameter, if that conversion might result in the loss of information".

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Huihuang Shi <huihuang.shi@intel.com>
2018-11-15 08:58:32 +08:00
Shiqing Gao d97224a4b5 hv: fix integer violations
fix the following integer violations:
1. Signed/unsigned conversion without cast
2. Literal value requires a U suffix
3. Implicit conversion of underlying type

v3 -> v4:
 * change the type of npk_loglevel/mem_loglevel/console_loglevel
   from uint32_t to uint16_t

v2 -> v3:
 * discard the return value of update_ept
 * discard changes related to npk loglevel

v1 -> v2:
 * remove the unnecessary changes related to the false positive
   issues caused by scanning tool
 * change the type of the local variable 'vlapic_id' from uint8_t
   to uint32_t in function 'vlapic_build_id'
 * change the type of the struct member 'flags' in shared_buf from
   uint64_t to uint32_t

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-14 12:46:34 +08:00
Huihuang Shi 7e6d0a2176 HV:pic fix "Recursion in procedure calls found"
Functions shall not call themselves, either directly or indirectly.

vpic_set_pinstate will cal vpic_notify_intr and results to recursion
violations,fix it out by mov vpic_notify_intr out of vpic_set_pinstate.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
reviewed-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-11-14 12:45:57 +08:00
Shiqing Gao 0a9d6841f7 hv: instr_emul: clean up mmio_read/mmio_write
clean up mmio_read/mmio_write in instr_emul.c
- make these two functions inline
- discard the return value and add the pre condition
- rename these two functions to vie_mmio_read/vie_mmio_write

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-14 09:18:40 +08:00
Binbin Wu 2c7c909e38 hv: vtd: fix the pre-allocated context table number
In current code, there is an out of range access to the array buses defined in struct struct context_table.
This patch defines CONFIG_IOMMU_BUS_NUM to replace CONFIG_IOMMU_INIT_BUS_LIMIT, which is clearer.
CONFIG_IOMMU_BUS_NUM equals to (CONFIG_IOMMU_INIT_BUS_LIMIT + 1).

Tracked-On: #1807
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-14 09:18:18 +08:00
Shiqing Gao 3731b4c0ac hv: fix '(void) missing for discarded return value'
MISRA-C requires that the function call in which the returned
value is discarded shall be clearly indicated using (void).

This patch fixes the violations related to the following
function calls.
- vlapic_set_intr
- vlapic_intr_edge

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2018-11-13 19:24:54 +08:00
Yonghua Huang b3b24320d4 hv: fix possible inconsistent issue for 'vm->hw.create_vcpus'
to decrease the value of 'create_vcpus' in fail case.

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-13 17:57:29 +08:00
Huihuang Shi 7bb09f75da fix "Procedure is not pure assembler"
Misra C reqires assembly code should comply with
the rules list below:
  The assembly code's functionality should match the function's
name.If not,pls encapsulate the assembly code and give a suitable
name for describing the functionality.
V1->V2:
    1.remove the dead code
    2.update detail comment

V2->V3:
    1.replace the macro name with upper case.
    2.remove the typedef and rename the struct name
"_descriptor_table_" to "descriptor_table".

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-13 16:28:58 +08:00
Yonghua Huang 91fb441d7a hv:add global lock for VM & vCPU management hypercalls
this patch is to avoid posisble inconsisent states for
 VMs and vCPUs in configuration that  SOS is SMP based
 and Device Model may be multi-threads based.

Tracked-On: #861
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-13 14:04:08 +08:00
Shiqing Gao 155675350d hv: unify the function pointer assignment
Assign function pointer without the unary & operator.

Take 'register_io_emulation_handler' as an example:
void register_io_emulation_handler(struct acrn_vm *vm,
                const struct vm_io_range *range,
                io_read_fn_t io_read_fn_ptr,
                io_write_fn_t io_write_fn_ptr)

The last two parameters are function pointer.
Sometimes we use function designator directly, while sometimes
with the unary & operator, as shown below.
 - without &
   register_io_emulation_handler(vm, &range, vuart_read, vuart_write);
 - with &
   register_io_emulation_handler(vm, &pci_cfg_range,
                   &pci_cfg_io_read, &pci_cfg_io_write);

To unify the coding style, we will go with the first way.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-13 13:34:36 +08:00
Mingqiang Chi 9a009bcef2 hv:Replace dynamic memory with static for mmio
-- Config MAX_EMULATED_MMIO_REGIONS 16 in Kconfig
-- Add emulated mmio array and emulated mmio regions
   in vm structure
-- Remove mmio list in vm structure
-- Remove unregister_mmio_emulation_handler and
   vioapic_cleanup APIs

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-11-13 11:52:48 +08:00
David B. Kinder b5505c43a2 doc: tweaks to 0.3 release notes
Fix a few spelling and presentation errors.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-11-12 10:57:47 -08:00
Geoffroy Van Cutsem a03452794f DM: update User OS launch script with v0.3 CL and kernel numbers
Update the User (guest) OS launch script with the Clear Linux
version used with ACRN v0.3 as well as the corresponding kernel
version.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-12 10:43:03 -08:00
Geoffroy Van Cutsem 1847497d8f Documentation: update GSG for release 0.3
Update Getting Started Guide (GSG) with Clear Linux version and
kernel versions for ACRN v0.3.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-12 10:43:03 -08:00
Geoffroy Van Cutsem 33137dc9fb Documentation: adjust "Tracked-On" capitalization in documentation
Update the capitalization of "Tracked-On" in the documentation.
"Tracked-on" should work but it throws a warning so it's better
to make the documentation focus on using "Tracked-On" only.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-11-12 09:47:57 -08:00
David B. Kinder f0ec5b26af doc: add Makefile option for singlehtml
Sphinx supports making a single (large) html file instead of a
full website with a collection of html pages.  This ``make singlehtml``
option provides the basis for creating a Word document (for example)
via a cut-and-paste of a section of the documentation (not easily
possible when the docs are in multiple HTML files.)

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-11-12 09:47:12 -08:00
Jack Ren d62196ac1f version: 0.4-unstable
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-11-12 17:38:52 +08:00
Jack Ren 43a3f120f3 version: v0.3
Signed-off-by: Jack Ren <jack.ren@intel.com>
2018-11-12 17:38:03 +08:00
Xie, nanlin aa36138151 Doc: update new known issues and features based into v0.3 release note
Signed-off-by: Xie, nanlin <nanlin.xie@intel.com>
2018-11-12 17:24:57 +08:00
David B. Kinder cb41e08006 doc: fix GSG version number typo
Update to NUC GSG had a version number typ0

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-11-10 11:21:02 -08:00
ailin,yang 5c8e4c38b7 DM: update clear Linux version
1, update Clear Linux version to 26120 
2, update kernel name to *iot-lts2018* 

Signed-off-by: Ailun258 ailin.yang@intel.com
2018-11-10 11:17:22 -08:00
ailin,yang bc2f30e229 HV: update kernel name
updated kernel name  from kernel-org.clearlinux.pk414-sos.4.14.52-63 to kernel-org.clearlinux.iot-lts2018-sos.4.19.0-16 for v0.3 release

Signed-off-by: Ailun258 <ailin.yang@intel.com>
2018-11-10 11:16:12 -08:00
ailin,yang 81cf2b6cf1 Doc: update doc to support V0.3 release
updates:  
1, update Clear Linux version to 26120 support v0.3 release
2,  update product kernel to kernel-iot-lts2018 since there is new named bundle 
Signed-off-by: Ailun258 <ailin.yang@intel.com>
2018-11-10 11:14:29 -08:00