Skip to content

Commit

Permalink
HV: add support for PIO bar emulation
Browse files Browse the repository at this point in the history
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: projectacrn#3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
  • Loading branch information
donsheng authored and junjiemao1 committed Jul 27, 2019
1 parent 3f737f4 commit 5a40a51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 3 additions & 7 deletions hypervisor/dm/vpci/pci_pt.c
Expand Up @@ -30,6 +30,7 @@
#include <errno.h>
#include <ept.h>
#include <mmu.h>
#include <vmx.h>
#include <logmsg.h>
#include "vpci_priv.h"

Expand Down Expand Up @@ -66,11 +67,6 @@ static uint64_t pci_bar_2_bar_base(const struct pci_bar *pbars, uint32_t nr_bars
enum pci_bar_type type = pci_get_bar_type(bar->reg.value);

switch (type) {
case PCIBAR_IO_SPACE:
/* IO bar, BITS 31-2 = base address, 4-byte aligned */
base = (uint64_t)(bar->reg.bits.io.base);
base <<= 2U;
break;

case PCIBAR_MEM32:
base = (uint64_t)(bar->reg.bits.mem.base);
Expand Down Expand Up @@ -258,6 +254,7 @@ static void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t offset, uint32_t
enum pci_bar_type type = pci_get_bar_type(vbar->reg.value);

switch (type) {

case PCIBAR_MEM32:
base = git_size_masked_bar_base(vbar->size, (uint64_t)val);
set_vbar_base(vbar, (uint32_t)base);
Expand Down Expand Up @@ -373,8 +370,7 @@ void init_vdev_pt(struct pci_vdev *vdev)
break;

default:
vbar->reg.value = 0x0U;
vbar->size = 0UL;
/* Nothing to do in this case */
break;
}
}
Expand Down
4 changes: 1 addition & 3 deletions hypervisor/include/hw/pci.h
Expand Up @@ -227,9 +227,7 @@ static inline enum pci_bar_type pci_get_bar_type(uint32_t val)
{
enum pci_bar_type type = PCIBAR_NONE;

if ((val & PCIM_BAR_SPACE) == PCIM_BAR_IO_SPACE) {
type = PCIBAR_IO_SPACE;
} else {
if ((val & PCIM_BAR_SPACE) != PCIM_BAR_IO_SPACE) {
switch (val & PCIM_BAR_MEM_TYPE) {
case PCIM_BAR_MEM_32:
case PCIM_BAR_MEM_1MB:
Expand Down

0 comments on commit 5a40a51

Please sign in to comment.