.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2017 Benjamin Herrenschmidt, IBM Corporation |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License, version 2, as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | 4 | */ |
---|
8 | 5 | |
---|
9 | 6 | #ifndef _KVM_PPC_BOOK3S_XIVE_H |
---|
.. | .. |
---|
11 | 8 | |
---|
12 | 9 | #ifdef CONFIG_KVM_XICS |
---|
13 | 10 | #include "book3s_xics.h" |
---|
| 11 | + |
---|
| 12 | +/* |
---|
| 13 | + * The XIVE Interrupt source numbers are within the range 0 to |
---|
| 14 | + * KVMPPC_XICS_NR_IRQS. |
---|
| 15 | + */ |
---|
| 16 | +#define KVMPPC_XIVE_FIRST_IRQ 0 |
---|
| 17 | +#define KVMPPC_XIVE_NR_IRQS KVMPPC_XICS_NR_IRQS |
---|
14 | 18 | |
---|
15 | 19 | /* |
---|
16 | 20 | * State for one guest irq source. |
---|
.. | .. |
---|
54 | 58 | bool saved_p; |
---|
55 | 59 | bool saved_q; |
---|
56 | 60 | u8 saved_scan_prio; |
---|
| 61 | + |
---|
| 62 | + /* Xive native */ |
---|
| 63 | + u32 eisn; /* Guest Effective IRQ number */ |
---|
57 | 64 | }; |
---|
58 | 65 | |
---|
59 | 66 | /* Select the "right" interrupt (IPI vs. passthrough) */ |
---|
.. | .. |
---|
84 | 91 | struct kvmppc_xive_irq_state irq_state[KVMPPC_XICS_IRQ_PER_ICS]; |
---|
85 | 92 | }; |
---|
86 | 93 | |
---|
| 94 | +struct kvmppc_xive; |
---|
| 95 | + |
---|
| 96 | +struct kvmppc_xive_ops { |
---|
| 97 | + int (*reset_mapped)(struct kvm *kvm, unsigned long guest_irq); |
---|
| 98 | +}; |
---|
87 | 99 | |
---|
88 | 100 | struct kvmppc_xive { |
---|
89 | 101 | struct kvm *kvm; |
---|
.. | .. |
---|
122 | 134 | |
---|
123 | 135 | /* Flags */ |
---|
124 | 136 | u8 single_escalation; |
---|
| 137 | + |
---|
| 138 | + /* Number of entries in the VP block */ |
---|
| 139 | + u32 nr_servers; |
---|
| 140 | + |
---|
| 141 | + struct kvmppc_xive_ops *ops; |
---|
| 142 | + struct address_space *mapping; |
---|
| 143 | + struct mutex mapping_lock; |
---|
| 144 | + struct mutex lock; |
---|
125 | 145 | }; |
---|
126 | 146 | |
---|
127 | 147 | #define KVMPPC_XIVE_Q_COUNT 8 |
---|
.. | .. |
---|
198 | 218 | return xive->src_blocks[bid]; |
---|
199 | 219 | } |
---|
200 | 220 | |
---|
| 221 | +static inline u32 kvmppc_xive_vp(struct kvmppc_xive *xive, u32 server) |
---|
| 222 | +{ |
---|
| 223 | + return xive->vp_base + kvmppc_pack_vcpu_id(xive->kvm, server); |
---|
| 224 | +} |
---|
| 225 | + |
---|
| 226 | +static inline bool kvmppc_xive_vp_in_use(struct kvm *kvm, u32 vp_id) |
---|
| 227 | +{ |
---|
| 228 | + struct kvm_vcpu *vcpu = NULL; |
---|
| 229 | + int i; |
---|
| 230 | + |
---|
| 231 | + kvm_for_each_vcpu(i, vcpu, kvm) { |
---|
| 232 | + if (vcpu->arch.xive_vcpu && vp_id == vcpu->arch.xive_vcpu->vp_id) |
---|
| 233 | + return true; |
---|
| 234 | + } |
---|
| 235 | + return false; |
---|
| 236 | +} |
---|
| 237 | + |
---|
201 | 238 | /* |
---|
202 | 239 | * Mapping between guest priorities and host priorities |
---|
203 | 240 | * is as follow. |
---|
.. | .. |
---|
248 | 285 | extern int (*__xive_vm_h_cppr)(struct kvm_vcpu *vcpu, unsigned long cppr); |
---|
249 | 286 | extern int (*__xive_vm_h_eoi)(struct kvm_vcpu *vcpu, unsigned long xirr); |
---|
250 | 287 | |
---|
| 288 | +/* |
---|
| 289 | + * Common Xive routines for XICS-over-XIVE and XIVE native |
---|
| 290 | + */ |
---|
| 291 | +void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu); |
---|
| 292 | +int kvmppc_xive_debug_show_queues(struct seq_file *m, struct kvm_vcpu *vcpu); |
---|
| 293 | +struct kvmppc_xive_src_block *kvmppc_xive_create_src_block( |
---|
| 294 | + struct kvmppc_xive *xive, int irq); |
---|
| 295 | +void kvmppc_xive_free_sources(struct kvmppc_xive_src_block *sb); |
---|
| 296 | +int kvmppc_xive_select_target(struct kvm *kvm, u32 *server, u8 prio); |
---|
| 297 | +int kvmppc_xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio, |
---|
| 298 | + bool single_escalation); |
---|
| 299 | +struct kvmppc_xive *kvmppc_xive_get_device(struct kvm *kvm, u32 type); |
---|
| 300 | +void xive_cleanup_single_escalation(struct kvm_vcpu *vcpu, |
---|
| 301 | + struct kvmppc_xive_vcpu *xc, int irq); |
---|
| 302 | +int kvmppc_xive_compute_vp_id(struct kvmppc_xive *xive, u32 cpu, u32 *vp); |
---|
| 303 | +int kvmppc_xive_set_nr_servers(struct kvmppc_xive *xive, u64 addr); |
---|
| 304 | + |
---|
251 | 305 | #endif /* CONFIG_KVM_XICS */ |
---|
252 | 306 | #endif /* _KVM_PPC_BOOK3S_XICS_H */ |
---|