Commit Graph

2917 Commits

Author SHA1 Message Date
Minggui Cao 61f03dae81 DOC: change PCI uart description from mmio to bdf
HV code changed to configure PCI uart mmio@ to bdf@,
so change its description to match it.

Tracked-On: #2031
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2018-12-20 11:53:13 -08:00
Shiqing Gao 50f5b0f6bb hv: vmexit: fix MISRA-C violations related to multiple exits
This patch fixes the MISRA-C violations in arch/x86/vmexit.c
 * make the function have only one exit point

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 23:05:13 +08:00
Li, Fei1 0a713e6fbc hv: coding style: refine set_vcpuid_entries to one exit
Fix procedure has more than one exit point.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-20 22:07:53 +08:00
Li, Fei1 a56abee9ff hv: coding style: refine find_vcpuid_entry
1) add local_find_vcpuid_entry to find whether a cpuid leaf exist
in vcpuid cache entries.
2) find_vcpuid_entry will return the found entry if local_find_vcpuid_entry
return is not null. Otherwise, call local_find_vcpuid_entry again
when necessary.
In this case, there could eliminate recursion in find_vcpuid_entry.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-20 22:07:53 +08:00
Minggui Cao 58d2a418d5 HV: fix pm code for multi-exits & unsigned const
1. change multi "return" to one exit.
2. add "U" to unsigned const as postfix.

Tracked-On: #861
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 21:56:48 +08:00
totoroow 97a7395183 dm: pass mac seed not to use vm name on UP2
Physical NIC mac address is used for generate UOS mac address.
This patch uses a new parameters to pass this information
instead of vm name.

Tracked-On: #1987
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2018-12-20 21:55:28 +08:00
Li, Fei1 1c99a975ea hv: coding style: refine trusty
Refine the reminding part: fix procedure has more than one exit point.

Tracked-On: #2120
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-20 21:53:51 +08:00
Li, Fei1 1dca17cd29 hv: coding style: refine initialize_trusty to one exit
1) Move data copy out of initialize_trusty
2) Fix procedure has more than one exit point

Tracked-On: #2120
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-20 21:53:51 +08:00
Li, Fei1 8a55f03823 hv: coding style: refine hcall_initialize_trusty to one exit
Fix procedure has more than one exit point.

Tracked-On: #2120
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-20 21:53:51 +08:00
Xiaoguang Wu 1d1d24345f DM USB: xHCI: change log level of some logs for S3 online debugging
S3 emulation is complicated and greatly dependent on system timing,
hence this patch changes log level for some important logs to help
online debugging (could output log by modifing launch_uos.sh and
without re-compiling)

Tracked-On: #1893
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>
2018-12-20 20:22:25 +08:00
Li, Fei1 5f0c093e57 hv: coding style: remove no real declaration for external variable
There is no no real declaration for these external variables. So just
remove them.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-20 20:20:08 +08:00
Kaige Fu 1e3358fd92 Debug: Add one hypercall to quary hardware info
acrntrace/log kernel modules will use this hypercall to fetch
pcpu num of hardware platform. Then, initialize driver accordingly.

Tracked-On: #1775;#1776
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
2018-12-20 18:48:38 +08:00
Mingqiang Chi 81a9de6067 hv:fix MISRA-C violations in create_vm
-- fix "more than one exit point" and "goto detected" violations
-- change prepare_vm0_memmap to void type
-- Add free_vm_id when create vm failed

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 18:47:57 +08:00
Zide Chen bb47184f3c hv: fix enable_msr_interception() function
Fixed three MISRA-C violations:
11S: No brackets to loop body
7C: Procedure has more than one exit point.
8D: DD data flow anomalies found.
  initialize read_map and write_map in the declaration statements.

Fixed one bug:
Use "msr <= 0x1FFFU" instead of "msr < 0x1FFFU" because 0x1FFF is a valid MSR
bitmap address.

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 18:46:19 +08:00
Shiqing Gao 56af4332e3 hv: io: fix MISRA-C violations related to multiple exits
This patch fixes the MISRA-C violations in arch/x86/io.c.
 * make the function have only one exit point

v1 -> v2:
 * replace `ASSERT` with `pr_err`

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 18:45:21 +08:00
Shiqing Gao c03bad1fef hv: io: fix MISRA-C violations related to style
This patch fixes the MISRA-C violations in arch/x86/io.c.
 * add the required brackets for logical conjunctions
 * add the required 'else' for 'if ... else if' case

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 18:45:21 +08:00
Li, Fei1 f27aa70fb5 hv: coding style: refine page related
1) Fix procedure has more than one exit point.
2) Add some brackets to make logical conjunctions more readable.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 15:44:08 +08:00
Huihuang Shi 7c2198c422 hv: config.h fix "Nested comment found."
The config.h generated by kconfiglib,the header contain "https://"
which will cause the static scan tool report "Nested comment found."
Remove it.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 14:09:50 +08:00
Zhao Yakui e22b35e332 HV/DM: Unify the usage of aligned for structure definition with alignment
Now one macro is added to define the alignment requirement.
>#define __aligned(x) __attribute__((aligned(x)))

Some code uses the __aligned(x) to define the alignment while the other
code uses the original alignment definition.
So they are unified.

Tracked-On: projectacrn/acrn-hypervisor#2131
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 14:08:28 +08:00
Binbin Wu 71a80d2d60 hv: assign: change ptirq vpin source type from enum to macro
This patch fixes the MISRA-C violations on implicit type conversion.
For ptirq vpin source type, there is no need to define a enum.
Remove enum ptirq_vpin_source.
Define two macro:
- PTDEV_VPIN_IOAPIC
- PTDEV_VPIN_PIC

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 13:43:47 +08:00
Binbin Wu d5865632ec hv: assign: remove added ptirq entries if fails to add all
When adding ptirq entries, either successes with all number of entries added or
fails with none entries addes.
So remove added ptirq entries if error occurs during the process.

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 13:43:47 +08:00
Binbin Wu d48dc38780 hv: assign: fix MISRA-C violations on multiple exits
This patch fixs the MISRA-C violations in arch/x86/assign.c
on multiple exits.

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 13:43:47 +08:00
Binbin Wu e8b3e44fc0 hv: assign: fix MISRA-C violations on potential null pointer deference
This patch fix the MISRA-C violations in arch/x86/assign.c
on potential null pointer deference.
Also add a break in case statement.

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 13:43:47 +08:00
Binbin Wu e19dcf5735 hv: assign: fix MISRA-C violations on implicit type conversion
This patch fixes the MISRA-C violations in arch/x86/assign.c
on implicit type conversion.

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 13:43:47 +08:00
Shiqing Gao 714814f97e hv: move `atoi` and `strtol_dec` to debug directory
This patch moves `atoi` and `strtol_dec` to debug directory
since they are only used by code under debug directory.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 12:52:59 +08:00
Shiqing Gao 32d6aa97f9 hv: string: fix MISRA-C violations related to style
This patch fixes the MISRA-C violations in lib/string.c
 * add the required brackets for logical conjunctions
 * replace the basic type `long` with defined type `int64_t`

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 12:52:59 +08:00
Shiqing Gao 2c6c383e54 hv: string: fix MISRA-C violations related to break
This patch fixes the MISRA-C violations in lib/string.c
 * make the while loop have only one `break`

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 12:52:59 +08:00
Minggui Cao b319e654c1 HV: fix bug adapt uart mmio to bdf for HV cmdline
now PCI uart changed from MMIO configure to BDF configure,
it need change this interface too; this interface is used
to dynamically configure debug uart by HV command line.

Tracked-On: #2031
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 10:11:02 +08:00
Minggui Cao 23c2166aa9 HV: change serial PCI cfg to bus:dev.func format
before PCI_BDF uses its hex value like "0xC2" for "0:18.2" to
configure, now use "0:18.2" directly to make it more readable
and easier to configure.

Tracked-On: #2031
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 10:11:02 +08:00
Huihuang Shi 1caf58f221 hv:clean io_request.c misra violations
Clean the io_request.c's violations reported by the misra tools.
V1->V2:
    remove violations which checked with NULL.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 09:10:02 +08:00
Yan, Like 530388db30 hv: irq: fix MISRA-C violations in irq.c and idt.h
This commit fixed following violations:
- Procedure has more than one exit point: free_irq_vector/request_irq/dispatch_interrupt
- goto detected: dispatch_interrupt
- Pointer param should be declared pointer to const: fixup_idt
- basic type declaration used: fixup_idt

Tracked-On: #861
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 09:09:31 +08:00
Yan, Like 08cf8f648c hv: lapic: fix MISRA-C violation of potential numeric overflow
This patch fixes the MISRA-C violations in arch/x86/lapic.c, change local variable from
uint32_t to uint64_t to avoid potential numeric overflow.

Tracked-On: #861
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-20 09:09:31 +08:00
Binbin Wu 83ebd43239 hv: ptdev: fix MISRAC violations
This patch fixs MISRAC violations in common/ptdev.c and include/common/ptdev.h

Tracked-On: #861
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-20 09:08:57 +08:00
Binbin Wu ccda4595bc dm: passthru: add error handling if msix table init failed
Release the resource reqeusted during msix table init if error occurs.
Change the type of the second arg of deinit_msix_table from pci_vdev to ptdev,
to align with init_msix_table.

Tracked-On: #1782
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2018-12-20 09:08:37 +08:00
Binbin Wu 3363779d8d dm: passthru: msi/msix handling revisit
Currently, the emulation of pci msi/msix can be handled by hypervisor code.
The logic in dm passthru driver can be simplified.

This patch remaps msix table to usersapce in DM passthru driver.
1. The access to the msix table in passthru driver will be trapped, and emulated by hv code.
2. The access to the config space in passthru driver will be trapped, and emulated by hv code.

So dm passthru driver no longer needs to keep the whole logic of handling msi/msix.
No need to do msix table remapping in sos kernel.
After the patch, the msix table ioremap code in vhm_dev.c can be removed.

Tracked-On: #1782
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
2018-12-20 09:08:37 +08:00
Li, Fei1 38c117841f hv: coding style: refine mmu.c
1) Separate ASM and C code inserts as pure procedures with a defined interface.
2) Fix procedure has more than one exit point.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2018-12-19 15:11:31 +08:00
Kaige Fu 2fefff34a7 HV: x86: fix "Global variable should be declared const"
Gloabal variable should be declared constant wherever possible to avoid unintentional
modification.

Tracked-On: #861
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 13:06:34 +08:00
Kaige Fu eff9459110 HV: x86: fix "Procedure has more than one exit point"
IEC 61508, ISO 26262 standards highly recommand single-exit rule.

Tracked-On: #861
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 13:06:34 +08:00
Shiqing Gao e283e77424 hv: vmcs: fix MISRA-C violations related to multiple exits
This patch fixes the MISRA-C violations in arch/x86/vmcs.c.
 * make the function have only one exit point

v1 -> v2:
 * update 'is_cr0_write_valid' and 'is_cr4_write_valid'
   use `if ... else` rather than check 'ret' value

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 13:04:23 +08:00
Shiqing Gao 4618a6b17d hv: vmcs: fix MISRA-C violations related to pointer
This patch fixes the MISRA-C violations in arch/x86/vmcs.c
and arch/x86/vmx.c.

 * add the required 'const' for pointer param if the object
   pointed by the pointer is not modified
 * remove the unnecessary cast on pointer

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 13:04:23 +08:00
Shiqing Gao 8e58a686f1 hv: vmcs: fix MISRA-C violations related to variable scope
This patch fixes the MISRA-C violations in arch/x86/vmcs.c.
 * add local variable if the input parameter passed by value
   is changed in function definition
 * move the variable declaration inside function scope if
   this variable is only used in one function

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 13:04:23 +08:00
Shiqing Gao 9a051e7ab2 hv: vmcs: fix MISRA-C violations related to style
This patch fixes the MISRA-C violations in arch/x86/vmcs.c.
 * add the missing space before or after binary operator
 * add the required brackets for logical conjunctions
 * remove the redefined MACROs

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 13:04:23 +08:00
Tianhua Sun 7d8cd911e1 security: remove gcc flags Wformat Wformat-security in HV
We have used the option --ffreestanding to assert hypervisor
is a freestanding environment, and hypervisor does not include
standard library.

"-Wformat/-Wformat-security"
Check calls to the standard library functions printf and scanf, etc.,
to make sure that the arguments supplied have types appropriate to
the format string specified, and that the conversions specified in
the format string make sense. these flags disabled by -ffreestanding
or -fno-builtin.

Tracked-On: #1122
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-19 13:03:34 +08:00
Zide Chen d133f95d97 hv: fix MISRA-C violations "Pointer param should be declared pointer to const."
MIRSA-C requires the const qualifier should be applied to pointer parameters
that address data not subject to change in rule 120D.

Tracked-On #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-19 13:03:03 +08:00
Minggui Cao f81fb21a58 HV: modularization to refine pm related code.
1. move out vm related code from arch/pm.
2. remove unnecssary global variables.
3. keep the global variables as static, not used
by other modules directlly.

Tracked-On: #1842
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-19 13:02:09 +08:00
Yonghua Huang 03262a96cf hv: refine coding style for ucode.c
- reduce exit points for 'acrn_update_ucode()' function.

Tracked-On: #2095
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 09:44:42 +08:00
Zide Chen 927c5172fa hv: vpci: fix MISRA-C violations related to variable declarations
78D: Global variable should be declared const.

Global variables should be declared constant wherever possible to
avoid unintentional modification.

27D: Variable should be declared static
  pci_ops_vdev_msi is not accessed by other files. Remove the declaration
  from the header and define it with the static qualifier; Because it's
  referenced by populate_msi_struct(), so move the define statements forward.

33D: No real declaration for external variable
  certain variables are available in sharing mode or partition mode only,
  so that the declarations in header files must be enclosed with
  CONFIG_PARTITION_MODE

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-19 09:21:24 +08:00
Zide Chen 4c28e98dc4 hv: refine a few functions to only one exit point
IEC 61508,ISO 26262 standards highly recommend single-exit rule.
7C: Procedure has more than one exit point.

Tracked-On: #861
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-19 09:17:30 +08:00
Mingqiang Chi 64a463000f hv:refine prepare_vm0 api
-- fix MISRA-C violation "procedure has more than one exit point"
   for this api
-- change start_vm to void type since it is always return 0

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-12-19 09:16:37 +08:00
Li, Fei1 b5e0efca82 hv: coding style: refine memory.c
1) Variable names shall start with a lower-case letter.
2) Multiplication and division come before addition and subtraction.
Everything else should be in parentheses.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-12-19 09:15:34 +08:00