Commit Graph

2063 Commits

Author SHA1 Message Date
yliu79 fe4fcf491f xHV: remove unused function is_dbg_uart_enabled
Change-Id: I64b3e08818f1cb15ec7c41557900d6e462c4e107
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
yliu79 36568ff5ea HV: remove unused function sbuf_is_empty and sbuf_get
Change-Id: I5fc3c472d445fc7a60c65e87cef692471ce6a26a
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
yliu79 c5391d2592 HV: remove unused function vcpu_inject_ac
Change-Id: I4b139e78c372d0941923fc8260db7a3578a894f2
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
yliu79 26de86d761 HV: remove unused function copy_to_gva
Change-Id: I18a6c860ba4bcec4e5915fa6a2a18ed1ecb20fff
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
yliu79 163c63d21f HV: remove unused function resume_vm
Change-Id: Ia6b6617e55044b5555a2d80c26a4ef7d7e56b7fa
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
yliu79 c68c6e4af2 HV: remove unused function shutdown_vcpu
Change-Id: Ia6f9aa4d2d603d23bc0cb9c3b12032d1a96504db
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
yliu79 83012a5a0a HV: remove unused function disable_iommu
Change-Id: Ia2347008082991d56cdbfab9f9940cfccc473702
Tracked-On: #3123
Signed-off-by: yliu79 <ying2.liu@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:36:03 +08:00
Minggui Cao 9b7dee90a6 HV: remove one lock for ctx->flags operation.
for ctx->flags is protected by scheduler lock, so not need
to set lock again.

Tracked-On: #3130

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:35:26 +08:00
Minggui Cao fc1cbebe31 HV: remove vcpu arch lock, not needed.
the pcpu just write its own vmcs, not need spinlock.
and the arch.lock not used other places, remove it too.

Tracked-On: #3130

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:35:26 +08:00
Minggui Cao 9876138b69 HV: add spinlock to dmar_enable/disable_qi
add spinlock to dmar_enable_qi & dmar_disable_qi to protect
struct dmar_unit variables; keep consistent with other same
level functions.

Tracked-On: #3130

Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 16:35:26 +08:00
Victor Sun 90f3ce442d HV: remove unused UNDEFINED_VM
The enum of UNDEFINED_VM has never been used, remove it;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
2019-05-22 10:01:20 +08:00
dongshen 73cff9ef08 HV: predefine pci vbar's base address for pre-launched VMs in vm_config
For pre-launched VMs, currently we set all vbars to 0s initially in
bar emulation code, guest OS will reprogram the bars when it sees the bars are uninited (0s).
We consider this is not the right solution, change to populate the
vbars (to non zero valid pci hole address) based on the vbar base
addresses predefined in vm_config.

Store a pointer to acrn_vm_pci_ptdev_config in struct pci_vdev

Tracked-On: #3022
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 10:00:15 +08:00
dongshen 4cdaa519a0 HV: rename vdev_pt_cfgwrite_bar to vdev_pt_write_vbar and some misra-c fix
Rename vdev_pt_cfgwrite_bar to vdev_pt_write_vbar

Misra-c violation fix:
 Add missing else for find_vdev()
 Fix more than one exit (return) in function
 vdev_pt_cfgwrite_bar/vdev_pt_write_vbar

Tracked-On: #3022
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-22 10:00:15 +08:00
Andy aba357dd36 1. fix cpu family calculation
2. Modifie the parameter 'fl' order

Tracked-On:#3142
Signed-off-by: Andy <andyx.liu@intel.com>
2019-05-21 10:37:17 +08:00
Jason Chen CJ 238d8bbaa2 reshuffle init_vm_boot_info
now only SOS need decide boot with de-privilege or direct boot mode, while
for other pre-launched VMs, they should use direct boot mode.

this patch merge boot/guest/direct_boot_info.c &
boot/guest/deprivilege_boot_info.c into boot/guest/vboot_info.c,
and change init_direct_vboot_info() function name to init_general_vm_boot_info().

in init_vm_boot_info(), depend on get_sos_boot_mode(), SOS may choose to init
vm boot info by setting the vm_sw_loader to deprivilege specific one; for SOS
using DIRECT_BOOT_MODE and all other VMS, they will use general_sw_loader as
vm_sw_loader and go through init_general_vm_boot_info() for virtual boot vm
info filling.

this patch also move spurious handler initilization for de-privilege mode from
boot/guest/deprivilege_boot.c to boot/guest/vboot_info.c, and just set it in
deprivilege sw_loader before irq enabling.

Changes to be committed:
	modified:   Makefile
	modified:   arch/x86/guest/vm.c
	modified:   boot/guest/deprivilege_boot.c
	deleted:    boot/guest/deprivilege_boot_info.c
	modified:   boot/guest/direct_boot.c
	renamed:    boot/guest/direct_boot_info.c -> boot/guest/vboot_info.c
	modified:   boot/guest/vboot_wrapper.c
	modified:   boot/include/guest/deprivilege_boot.h
	modified:   boot/include/guest/direct_boot.h
	modified:   boot/include/guest/vboot.h
	new file:   boot/include/guest/vboot_info.h
	modified:   common/vm_load.c
	modified:   include/arch/x86/guest/vm.h

Tracked-On: #1842
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-05-20 18:49:59 +08:00
dongshen 0018da4114 HV: add missing @pre for some functions
Add @pre for some functions, and fix outdated @pre statements

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-20 10:37:13 +08:00
dongshen b957802164 HV: unify the sharing_mode_cfgwrite and partition_mode_cfgwrite code
Put the cfgwrite code in write_cfg() for both sos and pre-launched VMs, and
remove sharing_mode_cfgwrite() and partition_mode_cfgwrite().

Rename functions used by write_cfg():
 vhostbridge_cfgwrite --> vhostbridge_write_cfg
 vdev_pt_cfgwrite --> vdev_pt_write_cfg
 vmsi_cfgwrite --> vmsi_write_cfg
 vmsix_cfgwrite --> vmsix_write_cfg

Fix @pre for functions

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-20 10:37:13 +08:00
dongshen 7635a68f38 HV: unify the sharing_mode_cfgread and partition_mode_cfgread code
Put the cfgread code in read_cfg() for both sos and pre-launched VMs, and
remove sharing_mode_cfgread() and partition_mode_cfgread().

Rename functions used by read_cfg():
 vhostbridge_cfgread --> vhostbridge_read_cfg
 vdev_pt_cfgread --> vdev_pt_read_cfg
 vmsi_cfgread --> vmsi_read_cfg
 vmsix_cfgread --> vmsix_read_cfg

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-20 10:37:13 +08:00
dongshen 19af3bc8aa HV: unify the sharing_mode_vpci_deinit and partition_mode_vpci_deinit code
Put the deinit code in deinit_prelaunched_vm_vpci() for both sos and pre-launched VMs, and
remove sharing_mode_vpci_deinit() and partition_mode_vpci_deinit().

Rename functions used by deinit():
 vhostbridge_deinit --> deinit_vhostbridge
 vmsi_deinit --> deinit_vmsi
 vmsix_deinit --> deinit_vmsix
 post_launched_vm_vpci_deinit --> deinit_post_launched_vm

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-05-20 10:37:13 +08:00
dongshen 3a6c63f2d8 HV: unify the sharing_mode_vpci_init and partition_mode_vpci_init code
Put the init code in init_vdev_for_pdev for both sos and pre-launched VMs, and
remove sharing_mode_vpci_init() and partition_mode_vpci_init().

Rename functions used by init_vdev_for_pdev:
 vhostbridge_init --> init_vhostbridge
 vmsi_init --> init_vmsi
 vmsix_init --> init_vmsix

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-05-20 10:37:13 +08:00
dongshen f873b843de HV: cosmetix fix for pci_pt.c
Use local variable msix instead of vdev->msix, vdev_pt_remap_msix_table_bar has
already defined a local variable msix (&vdev->msix), use msix instead of
vdev->msix to simplify the code.

Fix @pre for functions

Rename pci_bar_base to get_bar_base

Fix typo in comment

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-20 10:37:13 +08:00
dongshen cf48b9c38f HV: use is_prelaunched_vm/is_hostbridge to check if the code is only for pre-launched VMs
Currently host bridge emulation and bar emulation are only for pre-launched vms,
use is_prelaunched_vm to check if it is for pre-launched vms when calling
init/deinit/cfgread/cfgwrite, also use is_hostbridge() to check if the access if
for host bridge, so that these functions can be unified for sos and pre-launched
vm in subsequent commits.

Move is_hostbridge function to vpci_priv.h so that it can be used by multiple
files.

vhostbridge_cfgread/vhostbridge_cfgwrite: return -ENODEV if the pci cfg access is not
targeted for vhostbridge so that cfgread/cfgwrite functions can be unified for sos and
pre-launched vm in subsequent commits

Fix @pre for functions

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-05-20 10:37:13 +08:00
dongshen a97e6e6465 HV: rename sharing_mode_find_vdev_sos to find_vdev_for_sos
Rename the function to find_vdev_for_sos for the following reasons:
1. meet the <verb>_<nouns> function name guidelines
2. remove sharing_mode from the function name

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-20 10:37:13 +08:00
dongshen 32d1a9da02 HV: move bar emulation initialization code to pci_pt.c
Create the init_vdev_pt() function to host bar emulation initialization code

Add design philosophy for bar emulation

Move common functions to pci.h as they are generic and can be used by other
files.

Rename is_valid_bar to is_bar_supported and keep it as a private local function
in pci_pt.c

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-05-20 10:37:13 +08:00
Kaige Fu 67b2e2b82b HV: Remove undefined CONFIG_REMAIN_1G_PAGES
The definition of CONFIG_REMAIN_1G_PAGES has been removed by patch (4627cd4d HV: build: drop useless files).
So, remove the whole CONFIG_REMAIN_1G_PAGES in repo.

---
 v1 -> v2:
   Address Fei's comment about changing reserving_1g_pages from int32_t to int64_t
   Address Jason's comment about adding MACRO NUM_REMAIN_1G_PAGES

Tracked-On: #3128
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-05-17 11:06:52 +08:00
Mingqiang Chi 517cff1bbe hv:remove some unnecessary includes
remove some unnecessary includes,
some can cause reverse dependency.

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>

	modified:   acpi_parser/acpi_ext.c
	modified:   acpi_parser/dmar_parse.c
	modified:   boot/acpi_base.c
	modified:   boot/guest/direct_boot_info.c
	modified:   include/arch/x86/per_cpu.h
2019-05-16 10:33:01 +08:00
Zide Chen 865ee2956e hv: emulate ACPI reset register for Service OS guest
Handle the PIO reset register that is defined in host ACPI:

Parse host FADT table to get the host reset register info, and emulate
it for Service OS:

- return all '1' for guest reads because the read behavior is not defined
  in ACPI.
- ignore guest writes with the reset value to stop it from resetting host;
  if guest writes other values, passthru it to hardware in case the reset
  register supports other functionalities.

Tracked-On: #2700
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-15 11:20:12 +08:00
Zide Chen 26f08680eb hv: shutdown guest VM upon triple fault exceptions
This patch implements triple fault vmexit handler and base on VM types:

- post-launched VMs: shutdown_target_vm() injects S5 PIO write to request
  DM to shut down the target VM.
- pre-launched VMs: shut down the guest.
- SOS: similarly, but shut down all the non real-time post-launched VMs that
  depend to SOS before shutting down SOS.

Tracked-On: #2700
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-15 11:20:12 +08:00
Zide Chen 9aa3fe646b hv: emulate reset register 0xcf9 and 0x64
- post-launched RTVM: intercept both PIO ports so that hypervisor has a
  chance to set VM_POWERING_OFF flag.
- all other type of VMs: deny these 2 ports from guest access so that
  guests are not able to reset host.

Tracked-On: #2700
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-15 11:20:12 +08:00
Zide Chen 8ad0fd98a3 hv: implement NEED_SHUTDOWN_VM request to idle thread
For pre-launched VMs and SOS, VM shutdown should not be executed in the
current VM context.

- implement NEED_SHUTDOWN_VM request so that the BSP of the target VM can shut
  down the guest in idle thread.
- implement shutdown_vm_from_idle() to shut down target VM.

Tracked-On: #2700
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-15 11:20:12 +08:00
Victor Sun db952315c5 HV: fix MISRA violation of host_pm.h
The header need struct pm_s_state_data info which declared in acrn_common.h;

Tracked-On: #1842

Signed-off-by: Victor Sun <victor.sun@intel.com>
2019-05-15 09:31:43 +08:00
Victor Sun 1aac0dffaf HV: hot fix on usage of CONFIG_ACPI_PARSE_ENABLED
The acpi_fixup() is only called when CONFIG_ACPI_PARSE_ENABLED is enabled;

Tracked-On: #3107

Signed-off-by: Victor Sun <victor.sun@intel.com>
2019-05-15 09:31:21 +08:00
Li, Fei1 86f5993bc9 hv: vlapic: fix tpr virtualization when VID is not enabled.
1) According SDM Vol 3, Chap 29.1.2, Any VM exit caused by TPR virtualization
is trap-like: the instruction causing TPR virtualization completes before the VM
exit occurs (for example, the value of CS:RIP saved in the guest-state area of
the VMCS references the next instruction). So we need to retain the RIP.
2) The previous implement only consides the situation the guest will reduce the
TPR. However, the guest will increase it. So we need to update the PPR before we
find a deliverable interrupt. For examples: a) if the guest increase the TPR before
a irq windows vmexit, we need to update the PPR when check whether there has a pending
delivery interrupt or not; b) if the guest increase the TPR, then an external irq raised,
we need to update the PPR when check whether there has a deliverable interrupt to inject
to guest.

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-15 08:59:39 +08:00
Li, Fei1 a68dadb74a hv: vm: minor fix about vRTC
For prelaunched VM, Service OS and postlaunched RT VM, we only need the vRTC
provides backed-up date, so we could use the simple vRTC which implemented
in hypervisor. For postlaunched VM (which is not a RT VM), we needs the device
module to emulate the vRTC for it.

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
2019-05-15 08:59:39 +08:00
Victor Sun 8afbdb7505 HV: enable Kconfig of ACPI_PARSE_ENABLED
Previously we use Kconfig of DMAR_PARSE_ENABLED to choose pre-defined DMAR info
or parse it at runtime, at the same time we use MACRO of CONFIG_CONSTANT_ACPI
to decide whether parse PM related ACPI info at runtime. This looks redundant
so use a unified ACPI_PARSE_ENABLED Kconfig to replace them.

Tracked-On: #3107

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-14 11:53:02 +08:00
Victor Sun 86fe2e033c HV: split acpi.c
Split acpi.c to acpi_base.c and acpi_ext.c. The former one will
go FuSa and the later one will not;

Tracked-On: #3107

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-14 11:53:02 +08:00
Victor Sun cbab1f831c HV: remove acpi_priv.h
Keep acpi.h as the only acpi api interface;

Tracked-On: #3107

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-14 11:53:02 +08:00
Victor Sun 565f3cb72c HV: move dmar parse code to acpi parser folder
The acpi parse code would not go FuSa cert, move acpi parser related code
to a separate folder is helpful on FuSa isolation.

This patch moves dmar parse code;

Tracked-On: #3107

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-14 11:53:02 +08:00
Mingqiang Chi 397986913e hv:merge static_checks.c
now there are 2 static_checks.c,
./arch/x86/static_checks.c
./common/static_checks.c
they are used for static checks when build time,
this check should not belong to any HV layer from
modularization view, then add and move it to pre_build folder.

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
	modified:   Makefile
	deleted:    common/static_checks.c
	renamed:    arch/x86/static_checks.c -> pre_build/static_checks.c
2019-05-14 09:16:33 +08:00
Li, Fei1 bdae8efb7f hv: instr_emul: fix movzx return memory opsize wrong
There're some instructions which not support bit 0(w bit) flag but which
memory opcode size is fixed and the memory opcode size is not equal to the
register opcode size. In our code, there is movzx (which opcode is 0F B7)
which memory opcode size is fixed to 16 bits. So add a flag VIE_OP_F_WORD_OP
to indicate a instruction which memory opcode size is fixed to 16 bits.

Tracked-On: #1337
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-13 11:53:51 +08:00
Mingqiang Chi 795d6de0fb hv:move several files related X86 for lib
modified:   Makefile
renamed:    lib/memory.c -> arch/x86/lib/memory.c
renamed:    include/lib/atomic.h -> include/arch/x86/lib/atomic.h
renamed:    include/lib/bits.h -> include/arch/x86/lib/bits.h
renamed:    include/lib/spinlock.h -> include/arch/x86/lib/spinlock.h

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2019-05-13 10:12:20 +08:00
Mingqiang Chi 350d6a9eb6 hv:Move BUS_LOCK to atomic.h
now this MACRO is used in atomic.h and bits.h,
move it from cpu.h to atomic.h to avoid
reverse dependency(i.e. from lower layer to upper one)

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2019-05-13 10:12:20 +08:00
Shiqing Gao 7b8abe156c hv: refine 'init_percpu_lapic_id'
This patch refines 'init_percpu_lapic_id' to move the error
handling to 'init_pcpu_pre'.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-05-10 14:51:29 +08:00
Shiqing Gao dbb41575e7 hv: remove dynamic memory allocation APIs
This patch removes dynamic memory allocation APIs, including:
- calloc
- malloc
- free

The corresponding data structures, MACROs, and Kconfig items
are also removed.

v1 -> v2: no change

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-05-10 11:33:37 +08:00
Shiqing Gao 773889bb65 hv: dmar_parse: remove dynamic memory allocation
This patch removes the dynamic memory allocation in dmar_parse.c.

v1 -> v2:
 - rename 'const_dmar.c' to 'dmar_info.c' and move it to
   'boot' directory
 - add CONFIG_DMAR_PARSE_ENABLED check for function declaration

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-05-10 11:33:37 +08:00
Shiqing Gao 5629ade9a0 hv: add default DRHD MACROs in template platform acpi info
This patch adds default DRHD MACROs in template platform acpi info.

It is the preparation patch to remove dynamic memory allocation
in dmar_parse.c. So that the dmar info can be initialized with
default size and values when CONFIG_DMAR_PARSE_ENABLED is set
to y.

v1 -> v2: no change

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
2019-05-10 11:33:37 +08:00
Binbin Wu a581f50600 hv: vmsr: enable msr ia32_misc_enable emulation
Add MSR_IA32_MISC_ENABLE to emulated_guest_msrs to enable the emulation.
Init MSR_IA32_MISC_ENABLE for guest.

Tracked-On: #2834
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-09 16:35:15 +08:00
Binbin Wu 8e310e6ea1 hv: vcpuid: modify vcpuid according to msr ia32_misc_enable
According to SDM Vol4 2.1, modify vcpuid according to msr ia32_misc_enable:
- Clear CPUID.01H: ECX[3] if guest disabled monitor/mwait.
- Clear CPUID.80000001H: EDX[20] if guest set XD Bit Disable.
- Limit the CPUID leave maximum value to 2 if guest set Limit CPUID MAXVal.

Tracked-On: #2834
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-09 16:35:15 +08:00
Binbin Wu ef19ed8961 hv: vcpuid: reduce the cyclomatic complexity of function guest_cpuid
This patch reduces the cyclomatic complexity of the function guest_cpuid.

Tracked-On: #2834
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2019-05-09 16:35:15 +08:00
Binbin Wu f0d06165d3 hv: vmsr: handle guest msr ia32_misc_enable read/write
Guest MSR_IA32_MISC_ENABLE read simply returns the value set by guest.
Guest MSR_IA32_MISC_ENABLE write:
- Clear EFER.NXE if MSR_IA32_MISC_ENABLE_XD_DISABLE set.
- MSR_IA32_MISC_ENABLE_MONITOR_ENA:
  Allow guest to control this feature when HV doesn't use this feature and hw has no bug.

vcpuid update according to the change of the msr will be covered in following patch.

Tracked-On: #2834
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-09 16:35:15 +08:00