Commit Graph

3104 Commits

Author SHA1 Message Date
Zide Chen 86526cddc5 hv: disable more features from guest CPUID
Silicon Debug Feature: CPUID.01H.ECX[11]
- We can't allow guests to have direct access to silicon wide resources.

Machine Check Exception: CPUID.01H.EDX[5]
- Need HV support before exposing it to the guests.

Perfmon and Debug: CPUID.01H.ECX[15]
Debug Store: CPUID.01H.EDX[21], CPUID.01H.ECX[2], CPUID.01H.ECX[4]
- HV emulation is needed to separate host and guest monitoring data.
- guest CPUID.0AH is forced to all-zero in ACRN so it makes sense to clear
  these bits as well.

Tracked-On: #1867
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-01-09 23:04:41 +08:00
Zhao Yakui d094a39a7f DM: Try to load audio mediator BE driver before starting UOS
Currently whether audio works in virtio mediator or pass-through mode can be determined
by checking the device file of vbs_k_audio

But before the completion of loading audio virtio-BE module, the device file of /dev/vbs_k_audio
doesn't exist. In such case in course of loading UOS, the incorrect work mode is selected
for audio device (passthru instead of mediator). This is incorrect

Tracked-On: projectacrn/acrn-hypervisor#2247
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Alek Du <alek.du@intel.com>
2019-01-09 19:20:10 +08:00
Li, Fei1 1bc90293be hv: coding style: refine functions under dm/ to one exit point
Refine vioapic_indirect_write and vmsix_table_rw to one exit point.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-01-09 15:58:24 +08:00
Li, Fei1 087fbfe136 hv: coding style: remove basic type declaration use
Typedefs that indicate size and signedness should be used in place of
the basic numerical types

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-01-08 15:41:39 +08:00
Huihuang Shi e966828cd2 hv: clean the "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>
2019-01-08 14:47:01 +08:00
Shiqing Gao 2c6b43070b hv: code clean-up in `hw/pci.c`
* move `pci_pdev_calc_address` out of the spinlock in
   `pci_pdev_read_cfg`
 * remove the spaces before tabs
 * make the line not over 120 characters

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-08 14:45:52 +08:00
Shiqing Gao 2756ec740d hv: move `dm/hw/pci.c` to `hw/pci.c`
This patch moves `dm/hw/pci.c` to `hw/pci.c`

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-08 14:45:52 +08:00
Mingqiang Chi 7907fef59e hv:Rename several APIs for vpic and vioapic
vpic:
   vpic_set_irq         --> vpic_set_irqline
   vpic_get_irq_trigger --> vpic_get_irqline_trigger_mode
vioapic:
   vioapic_set_irq_nolock --> vioapic_set_irqline_nolock
   vioapic_set_irq        --> vioapic_set_irqline_lock
   vioapic_send_intr      --> vioapic_generate_intr

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2019-01-08 14:32:20 +08:00
Shiqing Gao 070a56dbc4 doc: rename register_io_emulation_handler
This is a follow-up patch in doc corresponding to the
changes in source code.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-01-08 11:28:13 +08:00
Shiqing Gao 272439d37f hv: rename register_io_emulation_handler
This patch renames `register_io_emulation_handler` to
`register_pio_emulation_handler`.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-08 11:28:13 +08:00
Tw d2b03e8c33 dm:script: remove ioc related stuff from uos on UP2
UP2 don't have ioc, there is no need to simulate it.

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-08 11:26:27 +08:00
Minggui Cao c00d959d43 HV: separate const dmar table definition from sbl
const dmar table is used for sbl board, and it can be
a single/independable file.

Tracked-On: #1842
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-08 08:46:15 +08:00
Minggui Cao c5e072432a HV: modularization to refine boot/bsp related code.
1. add static for local functions and variables.
2. move vm_sw_loader from vcpu to vm
3. refine uefi.c to follow the code rules.
4. separate uefi.c for vm0 boot and bsp two parts. bsp layer just
access native HW related, can't access vm/vcpu, vm0 boot part can
access vm / vcpu data structure.

Tracked-On: #1842
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-01-08 08:46:15 +08:00
David B. Kinder 4c541ba18c doc: spell check and formatting
Fix misspellings missed during regular reviews, and remove trailing
white space and Windows \r at end of lines.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-01-07 13:28:45 -08:00
root fad44184a5 doc: Descriptions about Dupont Wire used added 2019-01-07 11:56:01 -08:00
root 7f00e26021 doc: license header updated 2019-01-07 11:56:01 -08:00
root 10566e01b9 doc: update the statement 2019-01-07 11:56:01 -08:00
root e6d8ab2460 doc: update launch_uos.sh 2019-01-07 11:56:01 -08:00
root 6f1defcb31 doc: update the doc 2019-01-07 11:56:01 -08:00
Minggui Cao ef0f8b4ada DOC: add vuart setting guide to avoid conflict
different serial devices could be used on different boards.
"vuart=ttySn@irqN" is used to avoid vuart's irq conflict
with SOS passthrough devices.

on UEFI platform, if ttyS1 used for debug uart, and its IRQ
on native OS is 5, you'd better set "vuart=ttyS1@irq5"; also
for its SOS bootargs in acrn.conf, you need set "console=ttyS1"
to match its vuart setting.

Tracked-On: #2170
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
2019-01-07 11:28:38 -08:00
Mingqiang Chi 09ff94fc49 hv:Change structure boot_cpu_data to static
-- Change boot_cpu_data to static, only used in cpu_caps.c,
-- Add get_cpu_info() api, it will call this api instead of
   boot_cpu_data except cpu_caps.c

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-01-07 11:23:22 +08:00
Mingqiang Chi 7c4dd0d277 hv:Move pm state structure to pm.h
-- move structure 'cpu_state_info' from cpu_caps.h to host_pm.h
-- add get_cpu_pm_state_info() api

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-07 11:23:22 +08:00
Victor Sun ef0ef6ba52 HV: code style change for acpi.c
- rename biosacpi_search_rsdp() to found_rsdp();
- to make sure procedure has one exit point;

Tracked-On: #861
Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 17:53:38 +08:00
Victor Sun 351828d34b HV: code style change for reloc.c
move MACRO of R_X86_64_RELATIVE into #ifdef CONFIG_RELOC block;

Tracked-On: #861
Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 17:53:38 +08:00
Victor Sun 5c278cc57b HV: code style change for multiboot.c
- to make sure procedure has one exit point;

- add NULL pointer check;

Tracked-On: #861
Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 17:53:38 +08:00
Victor Sun dff6781293 HV: code style change for abl_seed_parse.c
- remove goto;

- make sure procedure has one exit point;

Tracked-On: #861
Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 17:53:38 +08:00
Victor Sun c572a9f503 HV: code style change for sbl_seed_parse.c
- remark unused MACRO;

- remove goto;

- make sure procedure has one exit point;

Tracked-On: #861
Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 17:53:38 +08:00
Zide Chen f4cce46605 hv: disable SMX (Safer Mode Extension) from guest CPUID
SMX should be disabled on guests.

Actually current code assumes SMX is disabled (no VM exit handler for GETSEC
and bit 2 of IA32_FEATURE_CONTROL is set), and this patch simply explicitly
clear guest CPUID.01H.ECX[6].

Since both CPUID.01H.ECX[5] and CPUID.01H.ECX[6] are cleared from guest CPUID,
MSR IA32_SMM_MONITOR_CTL is not available in guests.

Need to make sure CR4.SMXE is cleared in guests.

Tracked-On: #1867
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 16:05:50 +08:00
Zide Chen a4b166d5e8 hv: add missing MSRs to unsupported_msrs[]
SMRR (System-Management Range Register) is disabled from vMTRR,
so treat IA32_SMRR_PHYSBASE and IA32_SMRR_PHYSMASK as unsupported.

IA32_SMBASE is available only when IA32_VMX_MISC[15] is set.

IA32_FIXED_CTR0/1/2 are available only when CPUID.0AH:EDX[4:0] is non-zero.

Intel Processor Trace feature has been disabled and the associated MSRs
need to be in unsupported_msr[] as well.

Tracked-On: #1867
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-04 16:05:50 +08:00
yuhong.tao@intel.com 97cb7d906e hv: virq: fix wrong coding style
hypervisor/arch/x86/virq.c missed a new line at:

if (bitmap_test_and_clear_lock(...)) { vioapic_update_tmr(vcpu);

Tracked-On: #861
Acked-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2019-01-04 11:10:30 +08:00
Tianhua Sun 01c8f546e0 DM: xHCI: array bound checking before it is used
Array index of "vbdp_devs" may be out of bounds if
"i >= XHCI_MAX_VIRT_PORTS", so index checking is necessary.

Tracked-On: #1252
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-01-03 22:42:40 +08:00
Chaohong guo 8ed393a03d HV: remove multi-returns in few routine in guest.c
To meet MISRA, remove multi-returns in routines

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-03 15:58:10 +08:00
Chaohong guo e2c11c0c75 HV: remove multi returns in vlapic_set_apicbase
remove few calls to return statement in routines.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-03 15:58:10 +08:00
Chaohong guo 9efbdc829d HV: Remove goto in vlapic_read()
remove goto statement in vlapic_read() routine

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-03 15:58:10 +08:00
Chaohong guo 7a04db7cd8 HV: remove multiple exits in vlapic_set_intr_ready()
To meet MISRA, remove multiple return in the func.

Tracked-On: #861
Signed-off-by: Chaohong guo <chaohong.guo@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-01-03 15:58:10 +08:00
Tw b7fda27427 config: fix no serial output with SBL on UP2
SBL doesn't support 40-pin header for now, so the serial PCI
device(0:18:1) on it doesn't work. Let's just workaround this by
changing hv's default serial output device to 0:18:0. In the future,
we'd rather change it back if SBL supports it.

This change is only for SBL, for UEFI, now we offer serial configuration
through command line parameter(vuart=...).

Tracked-On: #1995
Signed-off-by: Tw <wei.tan@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@intel.com>
2019-01-03 13:01:07 +08:00
Chen Gang G ddf1c923ce hv: fix violations in md.c md.h and md_internal.h 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 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