Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: ivhsmem: Factor out architecture-specific parts
So far the ivshmem code assumed to run only on x86. In order to prepare it for reuse on other architectures (ARM, ARM64), factor out the bits and pieces that are arch-specific and implement them for x86. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
- Loading branch information
1 parent
e1ff6c5
commit 40cd9f5
Showing
7 changed files
with
127 additions
and
72 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Jailhouse, a Linux-based partitioning hypervisor | ||
* | ||
* Copyright (c) Siemens AG, 2016 | ||
* | ||
* Authors: | ||
* Jan Kiszka <jan.kiszka@siemens.com> | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2. See | ||
* the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#ifndef _JAILHOUSE_ASM_IVSHMEM_H | ||
#define _JAILHOUSE_ASM_IVSHMEM_H | ||
|
||
#include <asm/apic.h> | ||
|
||
struct arch_pci_ivshmem { | ||
struct apic_irq_message irq_msg; | ||
}; | ||
|
||
#endif /* !_JAILHOUSE_ASM_IVSHMEM_H */ |
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,71 @@ | ||
/* | ||
* Jailhouse, a Linux-based partitioning hypervisor | ||
* | ||
* Copyright (c) Siemens AG, 2014-2016 | ||
* | ||
* Author: | ||
* Henning Schild <henning.schild@siemens.com> | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2. See | ||
* the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#include <jailhouse/cell.h> | ||
#include <jailhouse/ivshmem.h> | ||
#include <jailhouse/pci.h> | ||
#include <jailhouse/printk.h> | ||
#include <asm/pci.h> | ||
|
||
void arch_ivshmem_write_doorbell(struct ivshmem_endpoint *ive) | ||
{ | ||
struct ivshmem_endpoint *remote = ive->remote; | ||
struct apic_irq_message irq_msg; | ||
|
||
if (!remote) | ||
return; | ||
|
||
/* get a copy of the struct before using it, the read barrier makes | ||
* sure the copy is consistent */ | ||
irq_msg = remote->arch.irq_msg; | ||
memory_load_barrier(); | ||
if (irq_msg.valid) | ||
apic_send_irq(irq_msg); | ||
} | ||
|
||
int arch_ivshmem_update_msix(struct pci_device *device) | ||
{ | ||
struct ivshmem_endpoint *ive = device->ivshmem_endpoint; | ||
union x86_msi_vector msi = { | ||
.raw.address = device->msix_vectors[0].address, | ||
.raw.data = device->msix_vectors[0].data, | ||
}; | ||
struct apic_irq_message irq_msg; | ||
|
||
/* before doing anything mark the cached irq_msg as invalid, | ||
* on success it will be valid on return. */ | ||
ive->arch.irq_msg.valid = 0; | ||
memory_barrier(); | ||
|
||
if (ivshmem_is_msix_masked(ive)) | ||
return 0; | ||
|
||
irq_msg = x86_pci_translate_msi(device, 0, 0, msi); | ||
if (!irq_msg.valid) | ||
return 0; | ||
|
||
if (!apic_filter_irq_dest(device->cell, &irq_msg)) { | ||
panic_printk("FATAL: ivshmem MSI-X target outside of " | ||
"cell \"%s\" device %02x:%02x.%x\n", | ||
device->cell->config->name, | ||
PCI_BDF_PARAMS(device->info->bdf)); | ||
return -EPERM; | ||
} | ||
/* now copy the whole struct into our cache and mark the cache | ||
* valid at the end */ | ||
irq_msg.valid = 0; | ||
ive->arch.irq_msg = irq_msg; | ||
memory_barrier(); | ||
ive->arch.irq_msg.valid = 1; | ||
|
||
return 0; | ||
} |
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