Commit Graph

2917 Commits

Author SHA1 Message Date
Chen Gang G c230a1a6c8 hv: fix violations in sha256.c for crypto lib
-remove goto
-remove multiple return
-Modify assignment operator in boolean expression
-Modify/fix code style violations
-fix attempt to change parameters passed by value
-fix value need U suffix
-fix use of mixed arithmetic
-fix assigment in expression
-other fixes

Tracked-On: #861
Signed-off-by: Chen Gang G <gang.g.chen@intel.com>
Reviewed-by: Bing Zhu <bing.zhu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-03 09:05:04 +08:00
Chen Gang G 488e7b2a8c hv: fix violations in hkdf.c and crypto_api.c for crypto lib
-remove goto
-remove multiple return
-Modify assignment operator in boolean expression
-Modify/fix code style violations
-fix attempt to change parameters passed by value
-fix value need U suffix
-fix use of mixed arithmetic
-fix assigment in expression
-other fix

Tracked-On: #861
Signed-off-by: Chen Gang G <gang.g.chen@intel.com>
Reviewed-by: Bing Zhu <bing.zhu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-03 09:05:04 +08:00
Chaohong guo 0884397361 HV: cycomatic complexity 20 in vlapic_icrlo_write_handler
MISRA compaint that the vlapic_icrlo_write_handler 's cyclomatic
complexity is greater than 20. Try to remove multiple returns/exits.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo eaa0e307b7 HV: remove multiple exit/return in routines in the file of vlapic.c
To meet MISRA, remove few return in routines of vlapic.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo 8e00180c9f HV: Remove goto statement in guest.c
To meet MISRA, remove some goto statements in guest.c

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo 2e01b4c8dc HV: trival changes to meet MISRA
add @pre for routines and bracks for condition checking in vlapic.c

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo 971eb84c20 HV: add const qualifier for functions' argments in vlapic.c
If a argment is not changed in function, MISRA recommends to add const
qualifier for that argement.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo 63eecf084e HV: remove multiple return statement in get_vcpu_paging_mode() routine
To meet MISRA, remove multiple return in get_vcpu_paging_mode() routine.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo b4b9ac593a HV: remove few return statement in while loop of copy_gva function
The coding style of multiple returns/exit in while loop is not MISRA
compatible. Remove the returns in while loop.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo 5a583fb87c HV: move global variable into the scope of calling function
The static global variable apicv_apic_access_addr is used only by
vlapic_apicv_get_apic_access_addr(), to remove the warning by MISRA,
move it into function scope.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Chaohong guo 235eaf057d HV: APICBASE_RESERVED definition is not used by any code. Just remove it
To meet MISRA standard, remove unused micro definition

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 16:22:11 +08:00
Shuang Zheng 04d9f52f68 update acrn-dm comment, remove the series of dot
Tracked-On: #2036
Signed-off-by: Shuang Zheng shuang.zheng@intel.com
2019-01-02 13:19:31 +08:00
yuhong.tao@intel.com 7a930d8833 hv: virq: refine hypervisor/arch/x86/virq.c
The MISRA-C Standards suggests use brackets to clarify the precedence
order of logical conjunctions.

Tracked-On: #861
Acked-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-01-02 12:49:44 +08:00
Minggui Cao 7ebc4877c8 HV: refine cmdline code, move parts into dbg_cmd
move the debug related command handle into debug/dbg_cmd.c;
so release build will not include that.

Tracked-On: #2170
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 12:15:53 +08:00
Minggui Cao a5ca305cf6 HV: add API to change vuart base & irq config
1. add an API to support vuart COM base and irq configured;
2. add the HV cmd to be parsed for vuart COM base & irq.

Tracked-On: #2170
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 12:15:53 +08:00
Minggui Cao f4beaf501c HV: support vuart base & irq can be changed
add two static variables for COM_BASE & COM_IRQ, to
support them dynamically changed.

Tracked-On: #2170
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 12:15:53 +08:00
Minggui Cao 537adaeb46 HV: cleanup CONFIG_COM_IRQ related code
move CONFIG_COM_IRQ code into vuart, because it is just
used for vuart.

Tracked-On: #2170
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 12:15:53 +08:00
Minggui Cao fde0bcc1ce HV: disable vuart when dbg uart is disabled
vuart it used for SOS to output log to HV console,
so if dbg uart is disabled, it need be disabled too:
just unregister its PIO.

Tracked-On: 2170
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-02 12:15:53 +08:00
Li, Fei1 860c444c55 hv: coding style: add `const` qualifier for some function
Add `const` qualifier for lookup_address and find_vcpuid_entry.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-01-02 09:35:00 +08:00
Li, Fei1 6f0edfc38d hv: coding style: use the defined data type __packed
1) Use __attribute__((packed)) instead of #pragma pack(1)
2) Use the defined data type __packed instead of __attribute__((packed))

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-01-02 09:35:00 +08:00
Peter Fang 40f6a9fdff dm: allow PM1_RTC_EN to be written to PM1A
Clear Linux complains about not being able to write the bit to PM1A:

ACPI Error: Could not enable RealTimeClock event (20180531/evxfevnt-184)

Tracked-On: #2176
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2018-12-29 10:33:32 +08:00
Peter Fang 57c661c48d dm: vrtc: add RTC to ACPI DSDT
Clear Linux complains about not finding RTC as a PNP device:

platform rtc_cmos: registered platform RTC device (no PNP device found)

This is a port of Bhyve vRTC's user-space logic.

Tracked-On: #2176
Signed-off-by: Peter Fang <peter.fang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
2018-12-29 10:33:32 +08:00
Binbin Wu 067273af18 hv: assign: fix remaining MISRA-C violations
This patch fixes the remaining MISRA-C violations in arch/x86/assign.c

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-29 10:32:09 +08:00
Yan, Like 1dfd05cdac hv: fix mis-usage of "PAGE_SHIFT"
Replace PAGE_SHIFT with MSI_ADDR_DEST_SHIFT in ptirq_build_physical_msi(), since it's not correct in semantics.

Tracked-On: #2209
Signed-off-by: Yan, Like <like.yan@intel.com>
2018-12-28 23:46:49 +08:00
Mingqiang Chi 5c6fe01c87 hv:Change pcpu_active_bitmap to static
-- Change pcpu_active_bitmap to static, only used in
   cpu.c
-- add get_pcpu_active_bitmap()

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-28 23:26:31 +08:00
Mingqiang Chi 682824de6d hv:Change phys_cpu_num to static
-- change phys_cpu_num to static
-- add get_pcpu_nums() and is_pcpu_active() APIs
-- replace phys_cpu_num with get_pcpu_nums() except cpu.c

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-28 23:26:31 +08:00
Binbin Wu 59e2de4805 dm: acpi: add PSDS table in ACPI table
Expose a new ACPI table PSDS to UOS.
This PSDS table show the security capability of the VM.
Only enable this table in UOS when PSDS presented in SOS.

Tracked-On: #888
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-28 22:11:09 +08:00
Tw 90fd5d5894 script: fix launch_uos script issue due to unseen character
Tracked-On: #1995
Space is tampered with unseen characters.
Reviewed-by: Binbin Wu <binbin.wu@intel.com>

Signed-off-by: Tw <wei.tan@intel.com>
2018-12-28 14:54:38 +08:00
David B. Kinder 9680009365 doc: update footer copyright year
Happy 2019!

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-12-27 17:06:51 -08:00
Min Lim 9c27ed1090 profiling: fix the profiling tool crash by page faults
Profiling tools are broken, which cause page faults during collection.
The issue happens by enabling SMAP recently. Therefore,
we use stac() and clac() to allow access to buffers allocated by guest.

Tacked-On: #2157
Signed-off-by: Min Lim <min.yeol.lim@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 16:24:38 +08:00
Shiqing Gao a177d75ed3 doc: initial draft of ACRN coding guidelines
This patch introduces an initial draft of ACRN coding guidelines.

We will update this document gradually to support ACRN achieve
MISRA-C compliance.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2018-12-26 22:46:46 -08:00
Huihuang Shi d89ce8aeb4 hv: schedule: fix "Procedure has more than one exit point"
Misra C requires Function must have only 1 return entry.
Fixed it by use "if ... else ..." format.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
2018-12-27 13:38:41 +08:00
Shuo A Liu 952943c3ea hv: decouple IO completion polling from idle thread
IO completion polling will access vcpu and vm structs. If doing it in
idle thread, there might be some race issues between vm destroying and
idle thread. They are running on different cores.
Got suggestion from Fengwei, decouple the polling action from idle
thread and just do it in vcpu thread, then we can guarantee idle thread
in really idle status.

Tracked-On: #1821
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-27 12:35:40 +08:00
Shuo A Liu a0154223f6 hv: clear NEED_RESCHEDULE flag in schedule
Now, need_reschedule will test_and_clear the bit NEED_RESCHEDULE in
schedule context, then call schedule. It is not a exact match with the
name.
This patch move the flag clearing into scheudle, and need_reschedule
just check and return.

Tracked-On: #1821
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 12:35:40 +08:00
Shuo A Liu e8ac97671f hv: use asm_pause() to replace inline ASM to satisfy MISRAC
pause_cpu() --> asm_pause()
hlt_cpu() --> asm_hlt()
inline ASM pause --> asm_pause()

Tracked-On: #1821
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 12:35:40 +08:00
Yin Fengwei 329ea42d73 dm: fix the memory leak in virtio mei
The possible memory leak was introduced by commit
7fce2462a0

If mevent add fails in virtio mei, the resource allocated doesn't
be released. This patch fix this memory leak issue.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2018-12-27 09:58:20 +08:00
Yin Fengwei 8f57c61da9 dm: Add teardown callback for mevent in uart_core
To avoid the race issue for mevent in uart, we introduce the
teardown callback to handle resource free case.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-27 09:58:20 +08:00
Yin Fengwei 72d1fa503a dm: refine the uart_core
Make uart_init and uart_deinit internal functions. And make
uart_set_backend/uart_release_backend cover uart_init/uart_deinit
function.

This will make mevent teardown callback adding easier for uart_core.

Tracked-On: #1877
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2018-12-27 09:58:20 +08:00
Binbin Wu 21aa1907fd hv: vcpuid: cpuid leaf 07h has subleaf
Two changes:

1. cpuid leaf 07h has subleaf:
According to SDM 3-194 Vol.2A, Table 3-8, cpuid leaf 07h has sub-leaves.
cpuid.07.eax reports the maximum input for sub-leaves.
Since there is no definition for subleaf > 0 in SDM, hv only supports subleaf 0.

2. In currently hv code, cpuid leaf function 14h is disabled,
CPUID.07H:EBX.INTEL_PROCESSOR_TRACE should be disabled as well.

Tracked-On: #2198
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 09:05:12 +08:00
Huihuang Shi 2d3f510dbe hv: tursty_hypercall: fix "Procedure has more than one exit point"
Misra C requires Function must have only 1 return entry.
Fixed it by use "if ... else ..." format.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 09:04:32 +08:00
Huihuang Shi 5aa7e29f0b hv: hypercall: fix "Procedure has more than one exit point"
Fix "Procedure has more than one exit point" by split the function into
two parts.
V1->V2:
    compact the multiple lines into one.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 09:04:15 +08:00
Huihuang Shi d6a2268282 hv: hypercall: fix complicated violations of "Procedure has more than one exit point"
Fix the complicated violations by methods list below:
1.if ... else ... fmt.
2.add status in proper position.
    example:
        bool bdf_valid;(could find this variable in this patch).

V1->V2:
    merge branches.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 09:04:15 +08:00
Huihuang Shi f680ed5d6a hv: hypercall: fix simple violations of "Procedure has more than one exit point"
This patch fix the violations by the "if ... else ..." fmt.

V1->V2:
    merge branches.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-27 09:04:15 +08:00
David B. Kinder 5ebaaaf973 doc: add CSS for non-compliant code examples
Coding guidelines have examples for compliant and non-compliant code,
but they look the same when rendered as HTML.  Add a CSS style for
non-compliant-code examples with a red-tinted background.

Usage is:
```
.. rst-class:: non-compliant-code

   .. code-block:: c

      a=b=c=0;
```
or, for example:

```
.. rst-class:: non-compliant-code

   Here's an example of non-compliant code::

      a=b=c=0;
```

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-12-26 11:09:46 -08:00
Tw e5c12a64d5 Makefile: add install-samples-up2
Add a rule to add UP2 related samples in rootfs.

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-12-26 16:19:59 +08:00
Tw 83034b7151 Makefile: specify BOARD&FIRMWARE in sb-hypervisor-install
BOARD&FIRMWARE are wrong When 'make sbl-hypervisor-install' w/o parameters
due to default platform is uefi. So set them clearly.

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-12-26 16:19:59 +08:00
Tw c932faa241 Makefile: eliminate mistakes due to deprecated PLATFORM
PLATFORM is deprecated, let's use it only for board detection

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-12-26 16:19:59 +08:00
Yonghua Huang 55691aed46 hv: fix coding style violations in mmu.c
Fix violations that attempt to change parameter
 passed by value.

Tracked-On: #2056
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-26 14:17:24 +08:00
Yonghua Huang c1fc7f5fce hv: remove the usage of 'atoi()'
this function is not from libc but has the same name,
  atoi() in libc is unbounded and not safe.

  replace this function with 'strtol_deci()' in this case.

Tracked-On: #2187
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-26 13:50:26 +08:00
Shuo Liu 536ce5fb27 dm: remove unnecessary ioreq status changing from DM
We will mark ioreq as COMPLETE in VHM via IC_NOTIFY_REQUEST_FINISH
ioctl. vm_notify_request_done can do it. So remove this one.

Tracked-On: #1821
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-26 13:49:44 +08:00