-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM: arm64: vgic-its: Introduce ITS emulation file with MMIO framework
The ARM GICv3 ITS emulation code goes into a separate file, but needs to be connected to the GICv3 emulation, of which it is an option. The ITS MMIO handlers require the respective ITS pointer to be passed in, so we amend the existing VGIC MMIO framework to let it cope with that. Also we introduce the basic ITS data structure and initialize it, but don't return any success yet, as we are not yet ready for the show. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Tested-by: Eric Auger <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
- Loading branch information
Showing
6 changed files
with
213 additions
and
13 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,103 @@ | ||
/* | ||
* GICv3 ITS emulation | ||
* | ||
* Copyright (C) 2015,2016 ARM Ltd. | ||
* Author: Andre Przywara <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* 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. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <linux/cpu.h> | ||
#include <linux/kvm.h> | ||
#include <linux/kvm_host.h> | ||
#include <linux/interrupt.h> | ||
|
||
#include <linux/irqchip/arm-gic-v3.h> | ||
|
||
#include <asm/kvm_emulate.h> | ||
#include <asm/kvm_arm.h> | ||
#include <asm/kvm_mmu.h> | ||
|
||
#include "vgic.h" | ||
#include "vgic-mmio.h" | ||
|
||
#define REGISTER_ITS_DESC(off, rd, wr, length, acc) \ | ||
{ \ | ||
.reg_offset = off, \ | ||
.len = length, \ | ||
.access_flags = acc, \ | ||
.its_read = rd, \ | ||
.its_write = wr, \ | ||
} | ||
|
||
static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its *its, | ||
gpa_t addr, unsigned int len) | ||
{ | ||
return 0; | ||
} | ||
|
||
static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its, | ||
gpa_t addr, unsigned int len, unsigned long val) | ||
{ | ||
/* Ignore */ | ||
} | ||
|
||
static struct vgic_register_region its_registers[] = { | ||
REGISTER_ITS_DESC(GITS_CTLR, | ||
its_mmio_read_raz, its_mmio_write_wi, 4, | ||
VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_IIDR, | ||
its_mmio_read_raz, its_mmio_write_wi, 4, | ||
VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_TYPER, | ||
its_mmio_read_raz, its_mmio_write_wi, 8, | ||
VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_CBASER, | ||
its_mmio_read_raz, its_mmio_write_wi, 8, | ||
VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_CWRITER, | ||
its_mmio_read_raz, its_mmio_write_wi, 8, | ||
VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_CREADR, | ||
its_mmio_read_raz, its_mmio_write_wi, 8, | ||
VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_BASER, | ||
its_mmio_read_raz, its_mmio_write_wi, 0x40, | ||
VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), | ||
REGISTER_ITS_DESC(GITS_IDREGS_BASE, | ||
its_mmio_read_raz, its_mmio_write_wi, 0x30, | ||
VGIC_ACCESS_32bit), | ||
}; | ||
|
||
static int vgic_its_init_its(struct kvm *kvm, struct vgic_its *its) | ||
{ | ||
struct vgic_io_device *iodev = &its->iodev; | ||
int ret; | ||
|
||
if (IS_VGIC_ADDR_UNDEF(its->vgic_its_base)) | ||
return -ENXIO; | ||
|
||
iodev->regions = its_registers; | ||
iodev->nr_regions = ARRAY_SIZE(its_registers); | ||
kvm_iodevice_init(&iodev->dev, &kvm_io_gic_ops); | ||
|
||
iodev->base_addr = its->vgic_its_base; | ||
iodev->iodev_type = IODEV_ITS; | ||
iodev->its = its; | ||
mutex_lock(&kvm->slots_lock); | ||
ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, iodev->base_addr, | ||
KVM_VGIC_V3_ITS_SIZE, &iodev->dev); | ||
mutex_unlock(&kvm->slots_lock); | ||
|
||
return ret; | ||
} |
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