76 DBGC2 ( hvm,
"HVM using CPUID base %#08x (v%d.%d)\n",
82 DBGC ( hvm,
"HVM could not find hypervisor\n" );
111 DBGC ( hvm,
"HVM could not allocate %d hypercall page(s)\n",
116 DBGC2 ( hvm,
"HVM hypercall page(s) at [%#08lx,%#08lx) via MSR %#08x\n",
117 hypercall_phys, ( hypercall_phys + hvm->
hypercall_len ), msr );
120 wrmsr ( msr, hypercall_phys );
124 if ( ( xenrc = xenver_extraversion ( &hvm->
xen, &
extraversion ) ) != 0){
126 DBGC ( hvm,
"HVM could not get extraversion: %s\n",
130 DBGC2 ( hvm,
"HVM found Xen version %d.%d%s\n",
171 DBGC ( hvm,
"HVM could not allocate %zd bytes of MMIO space " 172 "(%zd of %zd remaining)\n",
len,
180 DBGC ( hvm,
"HVM could not map MMIO space [%08lx,%08lx)\n",
188 for ( i = 0 ; i < pages ; i++ ) {
193 if ( ( xenrc = xenmem_add_to_physmap ( &hvm->
xen, &
add ) ) !=0){
195 DBGC ( hvm,
"HVM could not add space %d idx %d at " 196 "[%08lx,%08lx): %s\n", space, i,
198 ( mmio_phys + ( ( i + 1 ) *
PAGE_SIZE ) ),
200 goto err_add_to_physmap;
211 for ( i-- ; (
signed int ) i >= 0 ; i-- ) {
214 xenmem_remove_from_physmap ( &hvm->
xen, &
remove );
241 for ( i = 0 ; i < pages ; i++ ) {
244 if ( ( xenrc = xenmem_remove_from_physmap ( &hvm->
xen,
247 DBGC ( hvm,
"HVM could not remove space [%08lx,%08lx): " 248 "%s\n", ( mmio_phys + ( i *
PAGE_SIZE ) ),
249 ( mmio_phys + ( ( i + 1 ) *
PAGE_SIZE ) ),
274 DBGC2 ( hvm,
"HVM shared info page at [%#08lx,%#08lx)\n",
275 shared_info_phys, ( shared_info_phys +
PAGE_SIZE ) );
278 DBGC2 ( hvm,
"HVM wallclock time is %d\n",
311 DBGC ( hvm,
"HVM could not initialise grant table: %s\n",
323 DBGC2 ( hvm,
"HVM mapped grant table at [%08lx,%08lx)\n",
355 &xenstore_evtchn ) ) != 0 ) {
357 DBGC ( hvm,
"HVM could not get XenStore event channel: %s\n",
365 &xenstore_pfn ) ) != 0 ) {
367 DBGC ( hvm,
"HVM could not get XenStore PFN: %s\n",
371 xenstore_phys = ( xenstore_pfn *
PAGE_SIZE );
377 DBGC ( hvm,
"HVM could not map XenStore at [%08lx,%08lx)\n",
378 xenstore_phys, ( xenstore_phys +
PAGE_SIZE ) );
381 DBGC2 ( hvm,
"HVM mapped XenStore at [%08lx,%08lx) with event port " 382 "%d\n", xenstore_phys, ( xenstore_phys +
PAGE_SIZE ),
387 DBGC ( hvm,
"HVM could not read domain name: %s\n",
391 DBGC2 ( hvm,
"HVM running in domain \"%s\"\n",
name );
419 hvm =
zalloc (
sizeof ( *hvm ) );
427 DBGC2 ( hvm,
"HVM has MMIO space [%08lx,%08lx)\n",
437 goto err_map_hypercall;
439 goto err_map_shared_info;
443 goto err_map_xenstore;
447 DBGC ( hvm,
"HVM could not probe Xen bus: %s\n",
449 goto err_xenbus_probe;
489 PCI_ROM ( 0x5853, 0x0001,
"hvm",
"hvm", 0 ),
490 PCI_ROM ( 0x5853, 0x0002,
"hvm2",
"hvm2", 0 ),
int xengrant_init(struct xen_hypervisor *xen)
Initialise grant table.
size_t mmio_offset
Current offset within MMIO address space.
struct arbelprm_rc_send_wqe rc
static xen_extraversion_t * extraversion
#define HVM_CPUID_VERSION
Get Xen version.
static int xen_hvm_get_param(struct xen_hypervisor *xen, unsigned int index, uint64_t *value)
Get HVM parameter value.
static void hvm_unmap_hypercall(struct hvm_device *hvm)
Unmap hypercall page(s)
static void hvm_remove(struct pci_device *pci)
Remove PCI device.
static struct pci_device_id hvm_ids[]
PCI device IDs.
struct pci_device_id * ids
PCI ID table.
uint64_t add
Additional data length.
struct xen_hypervisor xen
Xen hypervisor.
#define HVM_PARAM_STORE_EVTCHN
#define HVM_PARAM_STORE_PFN
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define HVM_CPUID_MAGIC
Magic signature.
#define HVM_CPUID_MIN
Minimum CPUID base.
unsigned long long uint64_t
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
int xenstore_read(struct xen_hypervisor *xen, char **value,...)
Read XenStore value.
#define PAGE_SIZE
Page size.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
struct device dev
Generic device.
#define HVM_MMIO_BAR
PCI MMIO BAR.
#define EXEN(xenrc)
Convert a Xen status code to an iPXE status code.
Dynamic memory allocation.
int xenbus_probe(struct xen_hypervisor *xen, struct device *parent)
Probe Xen bus.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
u32 version
Driver version.
static uint32_t uint32_t uint32_t * ebx
struct shared_info * shared
Shared info page.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct pci_driver hvm_driver __pci_driver
PCI driver.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
static void hvm_unmap_xenstore(struct hvm_device *hvm)
Unmap XenStore.
static int hvm_map_shared_info(struct hvm_device *hvm)
Map shared info page.
struct grant_entry_v1 * table
Grant table entries.
struct xen_hypercall * hypercall
Hypercall table.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static int hvm_cpuid_base(struct hvm_device *hvm)
Get CPUID base.
static int hvm_probe(struct pci_device *pci)
Probe PCI device.
char * strerror(int errno)
Retrieve string representation of error number.
static uint32_t uint32_t uint32_t uint32_t * ecx
static void(* free)(struct refcnt *refcnt))
x86 CPU feature detection
void * zalloc(size_t size)
Allocate cleared memory.
static int hvm_map_hypercall(struct hvm_device *hvm)
Map hypercall page(s)
size_t hypercall_len
Length of hypercall table.
unsigned long mmio
MMIO base address.
evtchn_port_t port
Event channel.
static uint32_t uint32_t uint32_t uint32_t uint32_t * edx
#define ENODEV
No such device.
#define XENMAPSPACE_grant_table
static int hvm_map_xenstore(struct hvm_device *hvm)
Map XenStore.
#define HVM_CPUID_STEP
Increment between CPUID bases.
static void hvm_iounmap(struct hvm_device *hvm, void *mmio, size_t len)
Unmap MMIO space.
A PCI device ID list entry.
size_t mmio_len
Length of MMIO address space.
static void hvm_unmap_grant(struct hvm_device *hvm)
Unmap grant table.
char xen_extraversion_t[16]
uint16_t base
Base address.
static struct xen_remove_from_physmap * remove
static void * hvm_ioremap(struct hvm_device *hvm, unsigned int space, size_t len)
Allocate and map MMIO space.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define XENMAPSPACE_shared_info
struct xenstore_domain_interface * intf
XenStore domain interface.
int(* probe)(struct pci_device *pci)
Probe device.
struct xen_grant grant
Grant table.
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct xen_store store
XenStore.
void xenbus_remove(struct xen_hypervisor *xen __unused, struct device *parent)
Remove Xen bus.
static int hvm_map_grant(struct hvm_device *hvm)
Map grant table.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
size_t len
Total grant table length.
#define HVM_CPUID_MAX
Maximum CPUID base.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
static void hvm_unmap_shared_info(struct hvm_device *hvm)
Unmap shared info page.
#define HVM_CPUID_PAGES
Get number of hypercall pages.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
#define PCI_ROM(_vendor, _device, _name, _description, _data)
REQUIRING_SYMBOL(hvm_driver)
struct pci_device * pci
PCI device.
uint32_t cpuid_base
CPUID base.
Model-specific registers.