mirrored from git://xenbits.xen.org/xen.git
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xen/arm: Enable the existing x86 virtual PCI support for ARM
The existing VPCI support available for X86 is adapted for Arm. When the device is added to XEN via the hyper call “PHYSDEVOP_pci_device_add”, VPCI handler for the config space access is added to the Xen to emulate the PCI devices config space. A MMIO trap handler for the PCI ECAM space is registered in XEN so that when guest is trying to access the PCI config space,XEN will trap the access and emulate read/write using the VPCI and not the real PCI hardware. For Dom0less systems scan_pci_devices() would be used to discover the PCI device in XEN and VPCI handler will be added during XEN boots. This patch is also doing some small fixes to fix compilation errors on arm32 of vpci and prevent 64bit accesses on 32bit: - use %zu instead of lu in header.c for print - prevent 64bit accesses in vpci_access_allowed - ifdef out using CONFIG_64BIT handling of len 8 in vpci_ecam_{read/write} TODO: currently vpci_add_handlers is marked as __hwdom_init, but on ARM vpci_add_handlers can be called after boot from PHYSDEVOP_pci_device_add. Consider removing __hwdom_init. Signed-off-by: Rahul Singh <rahul.singh@arm.com> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> [stefano: add TODO item to commit message] Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com> Acked-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
- Loading branch information
Showing
10 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* xen/arch/arm/vpci.c | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
#include <xen/sched.h> | ||
#include <xen/vpci.h> | ||
|
||
#include <asm/mmio.h> | ||
|
||
static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info, | ||
register_t *r, void *p) | ||
{ | ||
pci_sbdf_t sbdf; | ||
/* data is needed to prevent a pointer cast on 32bit */ | ||
unsigned long data; | ||
|
||
/* We ignore segment part and always handle segment 0 */ | ||
sbdf.sbdf = VPCI_ECAM_BDF(info->gpa); | ||
|
||
if ( vpci_ecam_read(sbdf, ECAM_REG_OFFSET(info->gpa), | ||
1U << info->dabt.size, &data) ) | ||
{ | ||
*r = data; | ||
return 1; | ||
} | ||
|
||
*r = ~0ul; | ||
|
||
return 0; | ||
} | ||
|
||
static int vpci_mmio_write(struct vcpu *v, mmio_info_t *info, | ||
register_t r, void *p) | ||
{ | ||
pci_sbdf_t sbdf; | ||
|
||
/* We ignore segment part and always handle segment 0 */ | ||
sbdf.sbdf = VPCI_ECAM_BDF(info->gpa); | ||
|
||
return vpci_ecam_write(sbdf, ECAM_REG_OFFSET(info->gpa), | ||
1U << info->dabt.size, r); | ||
} | ||
|
||
static const struct mmio_handler_ops vpci_mmio_handler = { | ||
.read = vpci_mmio_read, | ||
.write = vpci_mmio_write, | ||
}; | ||
|
||
int domain_vpci_init(struct domain *d) | ||
{ | ||
if ( !has_vpci(d) ) | ||
return 0; | ||
|
||
register_mmio_handler(d, &vpci_mmio_handler, | ||
GUEST_VPCI_ECAM_BASE, GUEST_VPCI_ECAM_SIZE, NULL); | ||
|
||
return 0; | ||
} | ||
|
||
/* | ||
* Local variables: | ||
* mode: C | ||
* c-file-style: "BSD" | ||
* c-basic-offset: 4 | ||
* indent-tabs-mode: nil | ||
* End: | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* xen/arch/arm/vpci.h | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
#ifndef __ARCH_ARM_VPCI_H__ | ||
#define __ARCH_ARM_VPCI_H__ | ||
|
||
#ifdef CONFIG_HAS_VPCI | ||
int domain_vpci_init(struct domain *d); | ||
#else | ||
static inline int domain_vpci_init(struct domain *d) | ||
{ | ||
return 0; | ||
} | ||
#endif | ||
|
||
#endif /* __ARCH_ARM_VPCI_H__ */ | ||
|
||
/* | ||
* Local variables: | ||
* mode: C | ||
* c-file-style: "BSD" | ||
* c-basic-offset: 4 | ||
* indent-tabs-mode: nil | ||
* End: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters