Commit Graph

242 Commits

Author SHA1 Message Date
dongshen a092f40009 HV: make the functions void
The functions always return 0 so it makes sense to make them void functions

Tracked-On: #3475
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-29 09:58:57 +08:00
dongshen d6bf060573 HV: remove redundant function calling
The caller function has already done the checking to make sure the req is targeted
for the called functions, so there is no need to do the same checking in called
functions.

Remove calling of is_bar_offset() in vdev_pt_read_cfg/vdev_pt_write_cfg:
 In vpci.c's vpci_read_pt_dev_cfg and vpci_write_dev_cfg, vbar_access is called
 first to make sure the req is targed for vdev pt (vbar emulation) before
 dispatching the request to vdev_pt_read_cfg/vdev_pt_write_cfg, so there is no
 need to call is_bar_offset() again to do the same checking in vdev_pt_read_cfg/vdev_pt_write_cfg.

The same goes for msicap_access/msixcap_access

vbar_access should only check if the req is for bar access, it should not care
about whether the bar access is 4 bytes or 4 bytes aligned. The called function
vdev_pt_write_vbar will check and ignore the write access if it is not 4 bytes or 4 bytes
aligned, although this is counted as a bar access.

vdev_pt_read_vbar will check if the read access is 4 bytes or 4 bytes
aligned, although this is counted as a bar access, set read value (*val) to
-1 if the access is not 4 bytes (or aligned).

Tracked-On: #3475
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-29 09:58:57 +08:00
Li, Fei1 4a27d08360 hv: schedule: schedule to idel after SOS resume form S3
After "commit f0e1c5e init vcpu host stack when reset vcpu", SOS resume form S3
wants to schedule to vcpu_thread not the point where SOS enter S3. So we should
schedule to idel first then reschedule to execute vcpu_thread.

Tracked-On: #3387
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-07-29 09:53:18 +08:00
Yin Fengwei ce4d71e038 vpci: fix coding style issue
This is a followup patch to fix the coding style issue introduced
in by commit "c2d25aafb889ade954af8795df2405a94024d860":
  The unmodified pointer should be defined as const

Also addressed one comments from Fei to use reversed function call
in vpci_init_pt_dev and vpci_deinit_pt_dev.

Tracked-On: #3241
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-22 16:21:40 +08:00
Yin Fengwei cb9866bc6c softirq:spinlock: correct vioapic/vpic lock usage
Now, we are trying to move softirq from vcpu thread context to
real softirq context (it was not real softirq context even it has
softirq name), we need to make sure all the spinlock could be
access from softirq handler to use spinlock_irqsave_obtain and
spinlock_irqrestore_release.

Tracked-On: #3387
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-07-22 09:55:06 +08:00
Conghui Chen 05acc8b705 hv: vuart: bugfix for communication vuart
When a VM send data to its communication vuart, the vuart driver should
inject a DR interrupt to target VM and also inject a THRE interrupt to
self VM. But the original code inject the THRE interrupt to target VM,
correct it in this patch.

Tracked-On: #3423
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-18 09:28:27 +08:00
Yin Fengwei 009a16bd7d vhostbridge: update vhostbridge to use vdev_ops
And use vhostbridge for both SOS and pre-launched VM.

Tracked-On: #3241
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-15 10:35:47 +08:00
Yin Fengwei 9eba328bef vdev_ops: add general vdev ops
And use the ops based operations instead of direct access vdev
specific API.

Tracked-On: #3241
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-15 10:35:47 +08:00
Yin Fengwei 37de8f0b99 vbar:msi:msix: export vbar/msi/msix access checking
Change vbar/msi/msix access checking from private to public.

Tracked-On: #3241
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-15 10:35:47 +08:00
Huihuang Shi 714162fb8b HV: fix violations touched type conversion
ACRN Coding guidelines requires type conversion shall be explicity.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-11 09:16:09 +08:00
Li, Fei1 5930e96d12 hv: io_req: refine vhm_req status setting
In spite of vhm_req status could be updated in HV and DM on different CPUs, they
only change vhm_req status when they detect vhm_req status has been updated by
each other. So vhm_req status will not been misconfigured. However, before HV
sets vhm_req status to REQ_STATE_PENDING, vhm_req buffer filling should be visible
to DM. Add a write memory barrier to guarantee this.

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-07-11 09:15:47 +08:00
Huihuang Shi 564a60120a HV: fix vuart.c "Parameter needs to add const"
ACRN Coding guidelines requires parameters need to add const prefix when the
parameter is not modified in its function or recursion function call.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-09 10:36:44 +08:00
Mingqiang Chi e4d1c321ad hv:fix "no prototype for non-static function"
change some APIs to static or include header file

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
2019-07-09 10:36:03 +08:00
Cai Yulong 127c98f5db hv: vioapic: fix interrupt lost and redundant interrupt
1. reset polarity of ptirq_remapping_info to zero.
   this help to set correct initial pin state, and fix the interrupt lost issue
   when assign a ptirq to uos.

2. since vioapic_generate_intr relys on rte, we should build rte before
   generating an interrput, this fix the redundant interrupt.

Tracked-On: #3362
Signed-off-by: Cai Yulong <yulongc@hwtc.com.cn>
2019-07-05 10:22:56 +08:00
dongshen 012ec75163 HV: rename vbdf in struct pci_vdev to bdf
Rename vbdf to bdf for the following reasons:
Use the same coding style as struct pci_pdev, as pci_pdev uses bdf instead of pbdf

pci_vdev implies the its bdf is virtual, no need to prefix bdf with the v
prefix (redundant)

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-04 11:25:01 +08:00
dongshen 148e747349 HV: add support for PIO bar emulation
For PIO bar emulation, initially or when guest reprograms the PIO bar, allow guest
access for the specified bar base address (pio port) and sized by calling vev_pt_allow_io_vbar

For PIO bar emulation, just set the initial vbar base address equal to pbar
base address. For example, if the pbar base address is 0x2000, then set the
initial vbar base address also to 0x2000

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-04 11:25:01 +08:00
dongshen 4be09f24f3 HV: enable bar emulation for sos
For sos, its vbar base address is set to pbar base address (vbar gpa = pbar
hpa)

For pre-launched VMs, vbar base address is pre-assigned in vm_config

Rename vdev_pt_remap_msix_table_bar to vdev_pt_remap_msix_table_vbar and make it
a static function

Remove unused function prototye vdev_pt_remap_msix_table_bar() in vpci_priv.h

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-04 11:25:01 +08:00
dongshen af163d579f HV: add support for 64-bit bar emulation
Enable 64-bit bar emulation, if pbar is of type PCIBAR_MEM64, vbar will also be
of type PCIBAR_MEM64 instead of PCIBAR_MEM32

With 64-bit bar emulation code in place, we can remove enum pci_bar_type type
from struct pci_bar as bar type can be derived from struct pci_bar's reg member
by using the pci_get_bar_type function

Rename functions:
  pci_base_from_size_mask --> git_size_masked_bar_base

Remove unused functions

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-04 11:25:01 +08:00
dongshen ae996250c1 HV: extract functions from code to improve code reuse and readability
Create 2 functions from code:
 pci_base_from_size_mask
 vdev_pt_remap_mem_vbar

Use vbar in place of vdev->bar[idx] by setting vbar to &vdev->bar[idx]

Change base to uint64_t to accommodate 64-bit MMIO bar size masking in
subsequent commits

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 84e09a2246 HV: remove uint64_t base from struct pci_bar
At this point, uint64_t base in struct pci_bar is not used by any code, so we
can remove it.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 5a8703f764 HV: need to unmap existing EPT mapping for a vbar base (gpa)
Only do the EPT mapping if vbar base (gpa) is not mapped to the same pbar (hpa) before.
Need to unmap the existing mapping for a vbar base (gpa), otherwise, hv will
throw an error.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 0247c0b942 Hv: minor cosmetic fix
Define/Use variable in place of code to improve readability:

Define new local variable struct pci_bar *vbar, and use vbar-> in place of vdev->bar[idx].

Define new local variable uint64_t vbar_base in init_vdev_pt

Rename uint64_t vbar[PCI_BAR_COUNT] of struct acrn_vm_pci_ptdev_config to uint64_t vbar_base[PCI_BAR_COUNT]

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen f0244b24e7 HV: call get_vbar_base() to get the newly set vbar base address in 64-bit
Replace new_base with vbar_base in vdev_pt_remap_generic_mem_vbar().
We will call vdev_pt_remap_generic_mem_vbar() after a new vbar base
is set, no need to pass new_base to vdev_pt_remap_generic_mem_vbar(),
as this new vbar base (vbar_base) can be obtained by calling get_vbar_base().

The reason we call vdev_pt_remap_generic_mem_vbar() after a new vbar base
is set is for 64-bit mmio handling: when the lower 32-bit of 64-bit mmio vbar is
set, we will defer calling vdev_pt_remap_generic_mem_vbar until its upper 32-bit
vbar base is set.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen ed1bdcbbdf HV: add uint64_t bar_base_mapped[PCI_BAR_COUNT] to struct pci_vdev
To remember the previously mapped/registered vbar base

For the following reasons:
 register_mmio_emulation_handler() will throw an error if the the same addr_lo is
 alreayd registered before

 We are going to remove the base member from struct pci_bar, so we cannot use vdev->bar[idx].base
 in the code any more

 In subsequent commits, we will assume vdev_pt_remap_generic_mem_vbar() is called after a new
 vbar base is set, mainly because of 64-bit mmio bar handling, so we need a
 separate bar_base_mapped[] array to track the previously mapped vbar bases.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 65ca6ae498 HV: add get_vbar_base() to get vbar base address in 64-bit
vbar base can be built by using the base address fields stored in
struct pci_bar's reg member.

get_vbar_base: return vbar's base address in 64-bit. For 64-bit MMIO bar, its lower 32-bits
base address and upper 32-bits base are combined into one 64-bit base address

And changed related code to use get_vbar_base to get vbar base address in
64-bit.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 7a2f52441b HV: store the vbar base address in vbar's reg member
We added "union pci_bar_reg reg" to struct pci_bar in previous commit,
but only pci_pdev uses it and pci_vdev does not use it. Starting from
this commit, pci_vdev will use it:

In init_vdev_pt(), copy pbar's reg's flags portion to corresponding vbar's
reg.

When guest updates the vbar base address, the corresponding vbar reg's base
address will also be updated, so that in subsequent commits, we can eventually
remove the base member in struct pci_bar.

Rename local variable new_bar to base in vdev_pt_write_vbar

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 1b4dbdab70 HV: add get_pbar_base() to get pbar base address in 64-bit
pbar base can be built by using the base address fields stored in
struct pci_bar's reg member.

get_pbar_base: return pbar's base address in 64-bit. For 64-bit MMIO bar, its lower 32-bits
base address and upper 32-bits base are combined into one 64-bit base address

pci_bar_2_bar_base: helper function that is called by get_pbar_base

And changed related code to use get_pbar_base to get pbar base address in 64-bit

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen 8707834f83 HV: remove the function get_bar_base()
There is no need to call get_bar_base(), as new_bar is set to val & mask,
where mask is the bar size mask, so new_base has already been set to be the
bar base address before get_bar_base() is called on it.

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-07-01 09:57:05 +08:00
dongshen f7c4d2b5c4 HV: add uint32_t nr_bars to struct pci_vdev
Use nr_bars instead of PCI_BAR_COUNT to check bar access offset.
As while normal pci device has max 6 bars, pci bridge only has 2 bars,
so for pci normal pci device, pci cfg offsets 0x10-0x24 are for bar access,
but for pci bridge, only 0x10-0x14 are for bar access (0x18-0x24 are
for other accesses).

Rename function:
 pci_bar_access --> is_bar_offset

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-06-27 15:35:16 +08:00
dongshen 28d454bfb9 HV: move bar access and alignment checking out of vdev_pt_write_vbar
And put the checking in vdev_pt_write_cfg instead to have less nesting in
vdev_pt_write_vbar to improve code readability.

Rename function:
vdev_pt_remap_generic_bar --> vdev_pt_remap_generic_mem_vbar

vdev_pt_read_cfg's function declaration is merged into one line instead of 2
lines

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-06-27 15:35:16 +08:00
Huihuang Shi 3a61530d4e HV:fix simple violations
Fix the violations not touched the logical.
1.Function return value not checked.
2.Logical conjuctions need brackets.
3.No brackets to then/else.
4.Type conversion without cast.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
2019-06-25 20:09:21 +08:00
Huihuang Shi e3ee9cf20e HV: fix expression is not boolean
MISRA-C standard requires the type of result of expression in if/while pattern shall be boolean.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
2019-06-21 09:04:44 +08:00
Sainath Grandhi f7f2a6eef9 hv: Rename tables member of vPCI msix struct pci_msix
Rename MSI-X struct, pci_msix, member from tables to table_entries

Tracked-On: #3265
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-06-17 11:06:56 +08:00
Li, Fei1 9960ff98c5 hv: ept: unify EPT API name to verb-object style
Rename ept_mr_add to ept_add_mr
Rename ept_mr_modify to ept_modify_mr
Rename ept_mr_del to ept_del_mr

Tracked-On: #1842
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
2019-06-14 14:40:25 +08:00
Mingqiang Chi 8338cd463b hv: move 3 files to lib & arch folder
move stack_protector.c/retpoline-thunk.S into lib folder
move vmptable.c into arch/x86/config

Tracked-On: #1842
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>

	modified:   Makefile
	renamed:    arch/x86/retpoline-thunk.S -> arch/x86/lib/retpoline-thunk.S
	renamed:    common/stack_protector.c -> lib/stack_protector.c
	renamed:    dm/vmptable.c -> arch/x86/configs/vmptable.c
2019-06-14 14:22:51 +08:00
Zhao Yakui 296b649ae9 ACRN/HV: emulated pcicfg uses the aligned offset to fix the unaligned pci_cfg access
When the SOS kernel/pre-launched OS access the 0xCF8/0xCFC, it will cause
the vm-exit and then the hypervisor tries to emulate the PCI_cfg access.
0xCF8 write:  The bdf/reg is captured. cache_reg = value & (0xFF);
0xCFC-0xCFF read/write: offset = address - 0xCFC. Then cached_reg + offset is
used as the offset to access the pci_cfg.

If the aligned reg is passed in 0xCF8 register, it can work well. But when
the unaligned reg is passed in 0xCF8 register, the cached_reg + offset will cause
that the incorrect pci_cfg offset is accessed. For example:
   The cached_reg = 0x02(Device_ID offset) based on the value passed from 0xCF8
   offset = 2 based on 0xCFC-0xCFF address.
   Then cached_reg + offset is used as the offset(PCI_CMD_REG)

In fact the unaligned reg can work well on the real HW.

So the cached_reg should be aligned to handle the unaligned reg passed in
0xCF8 reg.

Tracked-On: #3249
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
2019-06-13 10:28:17 +08:00
Arindam Roy 2321fcdf78 HV:Modularize vpic code to remove usage of acrn_vm
V1:Initial Patch
Modularize vpic. The current patch reduces the usage
of acrn_vm inside the vpic.c file.
Due to the global natire of register_pio_handler, where
acrn_vm is being passed, some usage remains.
These needs to be a separate "interface" file.
That will come in smaller newer patch provided
this patch is accepted.

V2:
Incorporated comments from Jason.

V3:
Fixed some MISRA-C Violations.

Tracked-On: #1842
Signed-off-by: Arindam Roy <arindam.roy@intel.com>
Reviewed-by: Xu, Anthony <anthony.xu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-06-13 09:54:52 +08:00
Conghui Chen ac6c5dce81 HV: Clean vpic and vioapic logic when lapic is pt
When the lapic is passthru, vpic and vioapic cannot be used anymore. In
current code, user can still inject vpic interrupt to Guest OS, this is
not allowed.
This patch remove the vpic and vioapic initiate functions during
creating VM with lapic passthru. But the APIs in vpic and vioapic are
called in many places, for these APIs, follow the below principles:

1. For the APIs which will access uninitiated variables, and may case
hypervisor hang, add @pre to make sure user should call them after vpic or
vioapic is initiated.

2. For the APIs which only return some static value, do noting with them.

3. For the APIs which user will called to inject interrupt, such as
vioapic_set_irqline_lock or vpic_set_irqline, add condition in these
APIs to make sure it only inject interrupt when vpic or vioapic is
initiated. This change is to make sure the vuart or hypercall need not
to care whether lapic is passthru or the vpic and vioapic is initiated
or not.

Tracked-On: #3227
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
2019-06-12 14:29:50 +08:00
Victor Sun 50e09c41b4 HV: remove cpu_num from vm configurations
The vcpu num could be calculated based on pcpu_bitmap when prepare_vcpu()
is done, so remove this redundant configuration item;

Tracked-On: #3214

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
2019-06-06 15:22:10 +08:00
Conghui Chen 81cbc63646 HV: vuart: Bugfix for no interrupts on THRE
When enable Transmitter Holding Register Empty interrupts, vuart should
trigger interrupt when the THR is empty. In the previous code, only
after the data is written to THR, the flag thre_int_pending is set to
true. The thre_int_pending should also be true after THRE is set.
Besides, add logic to make sure interrupt is in right state when vuart
is initiated.

Tracked-On: #2987
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-06-03 09:15:16 +08:00
Sainath Grandhi 4c09051c7b hv: Remove unused variable in ptirq_msi_info
is_msix, part of ptirq_msi_info, is not used in the code.

Tracked-On: #3205
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-31 12:31:52 +08:00
Victor Sun f2fe35472b HV: remove mptable in vm_config
Define a static mptable array and each VM could index its vmptable by
vm id, then mptable is not needed in vm configurations;

Tracked-On: #2291

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-05-27 12:13:37 +08:00
dongshen d0fe18209c HV: call function is_prelaunched_vm() instead to reduce code
And make related changes accordingly:
 Remove calling of get_vm_config()
 Remove local variables vm and acrn_vm_config

Tracked-On: #3022
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-05-23 14:06:51 +08:00
dongshen a6503c6af3 HV: remove function pci_pdev_foreach()
And make other related changes accordingly:
 Remove pci_pdev_enumeration_cb define
 Create init_vdevs() to iterate through the pdev list and create vdev for each pdev
 Export num_pci_pdev and pci_pdev_array as globals in header file

Minor cosmetic fix:
 Remove trailing whitespace

Tracked-On: #3022
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
2019-05-23 14:06:51 +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
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