2019-06-03 08:44:50 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2016-12-19 22:25:00 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016,2017 ARM Limited, All Rights Reserved.
|
|
|
|
* Author: Marc Zyngier <marc.zyngier@arm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_IRQCHIP_ARM_GIC_V4_H
|
|
|
|
#define __LINUX_IRQCHIP_ARM_GIC_V4_H
|
|
|
|
|
|
|
|
struct its_vpe;
|
|
|
|
|
2017-10-08 20:48:06 +03:00
|
|
|
/*
|
|
|
|
* Maximum number of ITTs when GITS_TYPER.VMOVP == 0, using the
|
|
|
|
* ITSList mechanism to perform inter-ITS synchronization.
|
|
|
|
*/
|
|
|
|
#define GICv4_ITS_LIST_MAX 16
|
|
|
|
|
2016-12-19 22:25:00 +03:00
|
|
|
/* Embedded in kvm.arch */
|
|
|
|
struct its_vm {
|
|
|
|
struct fwnode_handle *fwnode;
|
|
|
|
struct irq_domain *domain;
|
|
|
|
struct page *vprop_page;
|
|
|
|
struct its_vpe **vpes;
|
|
|
|
int nr_vpes;
|
|
|
|
irq_hw_number_t db_lpi_base;
|
|
|
|
unsigned long *db_bitmap;
|
|
|
|
int nr_db_lpis;
|
2017-10-08 20:50:36 +03:00
|
|
|
u32 vlpi_count[GICv4_ITS_LIST_MAX];
|
2016-12-19 22:25:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Embedded in kvm_vcpu.arch */
|
|
|
|
struct its_vpe {
|
|
|
|
struct page *vpt_page;
|
|
|
|
struct its_vm *its_vm;
|
2019-11-07 19:04:11 +03:00
|
|
|
/* per-vPE VLPI tracking */
|
|
|
|
atomic_t vlpi_count;
|
2016-12-19 22:25:00 +03:00
|
|
|
/* Doorbell interrupt */
|
|
|
|
int irq;
|
|
|
|
irq_hw_number_t vpe_db_lpi;
|
KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put
When the VHE code was reworked, a lot of the vgic stuff was moved around,
but the GICv4 residency code did stay untouched, meaning that we come
in and out of residency on each flush/sync, which is obviously suboptimal.
To address this, let's move things around a bit:
- Residency entry (flush) moves to vcpu_load
- Residency exit (sync) moves to vcpu_put
- On blocking (entry to WFI), we "put"
- On unblocking (exit from WFI), we "load"
Because these can nest (load/block/put/load/unblock/put, for example),
we now have per-VPE tracking of the residency state.
Additionally, vgic_v4_put gains a "need doorbell" parameter, which only
gets set to true when blocking because of a WFI. This allows a finer
control of the doorbell, which now also gets disabled as soon as
it gets signaled.
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20191027144234.8395-2-maz@kernel.org
2019-10-27 17:41:59 +03:00
|
|
|
/* VPE resident */
|
|
|
|
bool resident;
|
2019-12-24 14:10:29 +03:00
|
|
|
union {
|
|
|
|
/* GICv4.0 implementations */
|
|
|
|
struct {
|
|
|
|
/* VPE proxy mapping */
|
|
|
|
int vpe_proxy_event;
|
|
|
|
/* Implementation Defined Area Invalid */
|
|
|
|
bool idai;
|
|
|
|
};
|
|
|
|
/* GICv4.1 implementations */
|
|
|
|
struct {
|
2020-03-04 23:33:21 +03:00
|
|
|
struct fwnode_handle *fwnode;
|
|
|
|
struct irq_domain *sgi_domain;
|
2020-03-04 23:33:15 +03:00
|
|
|
struct {
|
|
|
|
u8 priority;
|
|
|
|
bool enabled;
|
|
|
|
bool group;
|
|
|
|
} sgi_config[16];
|
2019-12-24 14:10:29 +03:00
|
|
|
atomic_t vmapp_count;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-03-04 23:33:10 +03:00
|
|
|
/*
|
|
|
|
* Ensures mutual exclusion between affinity setting of the
|
|
|
|
* vPE and vLPI operations using vpe->col_idx.
|
|
|
|
*/
|
|
|
|
raw_spinlock_t vpe_lock;
|
2016-12-19 22:25:00 +03:00
|
|
|
/*
|
|
|
|
* This collection ID is used to indirect the target
|
|
|
|
* redistributor for this VPE. The ID itself isn't involved in
|
|
|
|
* programming of the ITS.
|
|
|
|
*/
|
|
|
|
u16 col_idx;
|
|
|
|
/* Unique (system-wide) VPE identifier */
|
|
|
|
u16 vpe_id;
|
|
|
|
/* Pending VLPIs on schedule out? */
|
|
|
|
bool pending_last;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct its_vlpi_map: structure describing the mapping of a
|
|
|
|
* VLPI. Only to be interpreted in the context of a physical interrupt
|
|
|
|
* it complements. To be used as the vcpu_info passed to
|
|
|
|
* irq_set_vcpu_affinity().
|
|
|
|
*
|
|
|
|
* @vm: Pointer to the GICv4 notion of a VM
|
|
|
|
* @vpe: Pointer to the GICv4 notion of a virtual CPU (VPE)
|
|
|
|
* @vintid: Virtual LPI number
|
2017-10-26 12:44:07 +03:00
|
|
|
* @properties: Priority and enable bits (as written in the prop table)
|
2016-12-19 22:25:00 +03:00
|
|
|
* @db_enabled: Is the VPE doorbell to be generated?
|
|
|
|
*/
|
|
|
|
struct its_vlpi_map {
|
|
|
|
struct its_vm *vm;
|
|
|
|
struct its_vpe *vpe;
|
|
|
|
u32 vintid;
|
2017-10-26 12:44:07 +03:00
|
|
|
u8 properties;
|
2016-12-19 22:25:00 +03:00
|
|
|
bool db_enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum its_vcpu_info_cmd_type {
|
|
|
|
MAP_VLPI,
|
|
|
|
GET_VLPI,
|
|
|
|
PROP_UPDATE_VLPI,
|
|
|
|
PROP_UPDATE_AND_INV_VLPI,
|
|
|
|
SCHEDULE_VPE,
|
|
|
|
DESCHEDULE_VPE,
|
|
|
|
INVALL_VPE,
|
2020-03-04 23:33:19 +03:00
|
|
|
PROP_UPDATE_VSGI,
|
2016-12-19 22:25:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct its_cmd_info {
|
|
|
|
enum its_vcpu_info_cmd_type cmd_type;
|
|
|
|
union {
|
|
|
|
struct its_vlpi_map *map;
|
|
|
|
u8 config;
|
2019-12-24 14:10:34 +03:00
|
|
|
bool req_db;
|
|
|
|
struct {
|
|
|
|
bool g0en;
|
|
|
|
bool g1en;
|
|
|
|
};
|
2020-03-04 23:33:19 +03:00
|
|
|
struct {
|
|
|
|
u8 priority;
|
|
|
|
bool group;
|
|
|
|
};
|
2016-12-19 22:25:00 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-12-20 18:27:52 +03:00
|
|
|
int its_alloc_vcpu_irqs(struct its_vm *vm);
|
|
|
|
void its_free_vcpu_irqs(struct its_vm *vm);
|
2020-03-04 23:33:20 +03:00
|
|
|
int its_make_vpe_resident(struct its_vpe *vpe, bool g0en, bool g1en);
|
|
|
|
int its_make_vpe_non_resident(struct its_vpe *vpe, bool db);
|
2016-12-20 18:31:02 +03:00
|
|
|
int its_invall_vpe(struct its_vpe *vpe);
|
2016-12-22 00:50:32 +03:00
|
|
|
int its_map_vlpi(int irq, struct its_vlpi_map *map);
|
|
|
|
int its_get_vlpi(int irq, struct its_vlpi_map *map);
|
|
|
|
int its_unmap_vlpi(int irq);
|
|
|
|
int its_prop_update_vlpi(int irq, u8 config, bool inv);
|
2016-12-20 18:27:52 +03:00
|
|
|
|
2017-11-13 19:21:33 +03:00
|
|
|
struct irq_domain_ops;
|
2020-03-04 23:33:15 +03:00
|
|
|
int its_init_v4(struct irq_domain *domain,
|
|
|
|
const struct irq_domain_ops *vpe_ops,
|
|
|
|
const struct irq_domain_ops *sgi_ops);
|
2016-12-20 18:31:54 +03:00
|
|
|
|
2016-12-19 22:25:00 +03:00
|
|
|
#endif
|